Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scriptname SAM07_MancalaBoardSpotScript extends ObjectReference
- Event OnActivate(ObjectReference akActionRef)
- ; If Initially moving, then have the board stone count equal moving stone count, then set board stone count equal to zero and trigger next board spot
- if SAM_IsPlaying.GetValue() == 1 ; If it is 1, then now we disable the available choices, since it has been picked, and set value to 2
- if BoardSpotStoneCount >= 1 ; If this is an empty spot, don't go through
- SAM_IsPlaying.SetValue(2) ; 2 means that the player's turn is still going on, but player can not interact now.
- SAM_PlayerSideChoiceVisibilityRef.Disable(false) ; Disable Player Choices
- Debug.Notification("BoardSpotStoneCount =" + BoardSpotStoneCount )
- SAM_MovingStoneCount.SetValue(BoardSpotStoneCount) ; Pick up the stones from this slot. That means transfer integer from slot data to globalvariable
- BoardSpotStoneCount = 0
- NextBoardSpot.Activate(Self) ; Activate next spot in drop mode, which is "2"
- PHYDishWoodLSD.Play(Self)
- else
- ; Show Message notification: "This is an empty slot."
- SAM_MancalaBoardEmptySlotMessage.Show()
- endif
- elseif SAM_IsPlaying.GetValue() == 2 ; this is what plays on each subsequent spot, does not continue from above on same slot since it's elseif
- Utility.Wait(1.5) ; Wait half a second to slow down the game, more observable to see what's going on, and unclog some script..?
- if SAM_MovingStoneCount.GetValue() >= 1 ;If we still have stones, keep going, else end the turn
- if SAM_WhoPlaying.GetValue() == 1 ; This is for the storerooms, big slots on the sides. 1 is 1, 2 is 9, slot wise. Check which side you're playing.
- If Self != House2 ; House that Player 1 cannot go to.
- BoardSpotStoneCount = BoardSpotStoneCount + 1 ; Checks to see how many stones are moving, if there's at least one, it takes one from that stone and adds it to this slot's count
- SAM_MovingStoneCount.Mod(-1)
- PHYDishWoodLSD.Play(SAM_BoardSoundRef)
- if SAM_MovingStoneCount.GetValue() < 0 ;make sure we don't get a negative here
- SAM_MovingStoneCount.SetValue(0)
- endif
- Debug.Notification("BoardSpotStoneCount =" + BoardSpotStoneCount )
- NextBoardSpot.Activate(Self) ; continue distribution of stones
- else
- NextBoardSpot.Activate(Self) ; continue distribution of stones, this is the one that does not drop stones, since it is opponnent's storeroom
- endif
- elseif SAM_WhoPlaying.GetValue() == 2 ; This is for the storerooms, big slots on the sides. 1 is 1, 2 is 9, slot wise. Check which side you're playing.
- If Self != House1 ; House that Player 2 cannot go to.
- BoardSpotStoneCount = BoardSpotStoneCount + 1 ; Checks to see how many stones are moving, if there's at least one, it takes one from that stone and adds it to this slot's count
- SAM_MovingStoneCount.Mod(-1)
- PHYDishWoodLSD.Play(Self)
- if SAM_MovingStoneCount.GetValue() < 0 ;make sure we don't get a negative here
- SAM_MovingStoneCount.SetValue(0)
- endif
- Debug.Notification("BoardSpotStoneCount =" + BoardSpotStoneCount )
- NextBoardSpot.Activate(Self) ; continue distribution of stones
- else
- NextBoardSpot.Activate(Self) ; continue distribution of stones, this is the one that does not drop stones, since it is opponnent's storeroom
- endif
- else
- ; This slot is empty.
- ; The other person's turn now.
- ; This is setting SAM_IsPlaying to 1 because we're currently testing.
- SAM_IsPlaying.SetValue(1)
- SAM_PlayerSideChoiceVisibilityRef.Enable()
- Debug.Notification("Ended on "+ BoardSpotNumber)
- endif
- endif
- endif
- Utility.Wait(1)
- ; This section is for the board spot's visual appearance. It enables/disables the stones here depending on how many it has.
- if BoardSpotStoneCount >= 14
- SpotStone14.Enable()
- else
- SpotStone14.Disable()
- endif
- if BoardSpotStoneCount >= 13
- SpotStone13.Enable()
- else
- SpotStone13.Disable()
- endif
- if BoardSpotStoneCount >= 12
- SpotStone12.Enable()
- else
- SpotStone12.Disable()
- endif
- if BoardSpotStoneCount >= 11
- SpotStone11.Enable()
- else
- SpotStone11.Disable()
- endif
- if BoardSpotStoneCount >= 10
- SpotStone10.Enable()
- else
- SpotStone10.Disable()
- endif
- if BoardSpotStoneCount >= 9
- SpotStone09.Enable()
- else
- SpotStone09.Disable()
- endif
- if BoardSpotStoneCount >= 8
- SpotStone08.Enable()
- else
- SpotStone08.Disable()
- endif
- if BoardSpotStoneCount >= 7
- SpotStone07.Enable()
- else
- SpotStone07.Disable()
- endif
- if BoardSpotStoneCount >= 6
- SpotStone06.Enable()
- else
- SpotStone06.Disable()
- endif
- if BoardSpotStoneCount >= 5
- SpotStone05.Enable()
- else
- SpotStone05.Disable()
- endif
- if BoardSpotStoneCount >= 4
- SpotStone04.Enable()
- else
- SpotStone04.Disable()
- endif
- if BoardSpotStoneCount >= 3
- SpotStone03.Enable()
- else
- SpotStone03.Disable()
- endif
- if BoardSpotStoneCount >= 2
- SpotStone02.Enable()
- else
- SpotStone02.Disable()
- endif
- if BoardSpotStoneCount >= 1
- SpotStone01.Enable()
- else
- SpotStone01.Disable()
- endif
- ; Build up a store of the references being moved
- ;MovingMarble01Ref
- ;Float DestinationSlotXCoord = DestinationSlot.GetXCoord()
- ;Float DestinationSlotYCoord = DestinationSlot.GetYCoord()
- ;Float DestinationSlotZCoord = DestinationSlot.GetZCoord()
- ;Float DestinationSlotSpotXCoord = DestinationSlot.GetXCoord()
- ;Float DestinationSlotSpotYCoord = DestinationSlot.GetYCoord()
- ;Float DestinationSlotSpotZCoord = DestinationSlot.GetZCoord()
- ;DestinationSlot is defined by the slot this board spot script is attached to
- ;DestinationSlotSpot is defined by the random selection of a spot using an array
- ; Generate the slot for our number
- Int RandomSpotNumber = Utility.RandomInt(1 , 28) ;Randomly pick a number
- string[] myArray = new string[4]
- if SAM_SlotExistingMarbles01 != None
- myArray[0] = "1"
- endif
- if SAM_SlotExistingMarbles02 != None
- myArray[0] = "2"
- endif
- if SAM_SlotExistingMarbles03 != None
- myArray[0] = "3"
- endif
- if SAM_SlotExistingMarbles04 != None
- myArray[0] = "4"
- endif
- if SAM_SlotExistingMarbles05 != None
- myArray[0] = "5"
- endif
- ;;;; if RandomSpotNumber == ;an existing spot number for this slot, aka, marble is in the place this wants to be, then manually adjust it
- if myArray.Find(RandomSpotNumber) < 0
- Debug.Trace("The Spot Wasn't In Our Array!")
- else
- Debug.Trace("The Spot Was In Our Array!")
- ; Change RandomSpotNumber and then retry, this is why we have array!
- if RandomSpotNumber < 28
- RandomSpotNumber += 1
- else
- RandomSpotNumber = 1 ;Go back down to One if we're at max
- endIf
- endif
- if RandomSpotNumber == 1 ;Assign the spots
- SAM_DestinationSlotSpotRef01 = SAM_DestinationSlotSpot
- elseif RandomSpotNumber == 2
- SAM_DestinationSlotSpotRef02 = SAM_DestinationSlotSpot
- elseif RandomSpotNumber == 3
- SAM_DestinationSlotSpotRef03 = SAM_DestinationSlotSpot
- elseif RandomSpotNumber == 4
- SAM_DestinationSlotSpotRef04 = SAM_DestinationSlotSpot
- elseif RandomSpotNumber == 5
- SAM_DestinationSlotSpotRef05 = SAM_DestinationSlotSpot
- endif
- Float DestinationSlotXCoord = SAM_DestinationSlot.GetPositionX()
- Float DestinationSlotYCoord = SAM_DestinationSlot.GetPositionY()
- Float DestinationSlotZCoord = SAM_DestinationSlot.GetPositionZ()
- Float DestinationSlotSpotXCoord = SAM_DestinationSlotSpot.GetPositionX()
- Float DestinationSlotSpotYCoord = SAM_DestinationSlotSpot.GetPositionY()
- Float DestinationSlotSpotZCoord = SAM_DestinationSlotSpot.GetPositionZ()
- Float SetDestinationSlotSpotXCoord = DestinationSlotSpotXCoord + DestinationSlotXCoord
- Float SetDestinationSlotSpotYCoord = DestinationSlotSpotYCoord + DestinationSlotYCoord
- Float SetDestinationSlotSpotZCoord = DestinationSlotSpotZCoord + DestinationSlotZCoord
- ; We use this to derive the position of the House as well as the spot inside the individual House to offset the marble by.
- ; Make ObjectReferences that are saved as the ones on this spot from RandomInt
- ; Make ObjectReferences that are defined as the ones in SAM_MancalaMath
- ;FreeSpots ; These are the spots of the grid that are free.
- ; This will randomly move our marble to a free spot at our destination!
- ; Or maybe pre-determined, mmmm
- ;string[] PotentialSpot = new string[28]
- ;PotentialSpot [0] = "SAM_MarbleSpot01Ref"
- if akActionRef == Game.GetPlayer()
- if SAM_IsPlaying.GetValue() == 0
- Debug.Notification( BoardSpotStoneCount + " pieces on spot " + BoardSpotNumber)
- endif
- endif
- EndEvent
- Int Property BoardSpotNumber Auto
- Int Property BoardSpotStoneCount Auto
- ObjectReference Property NextBoardSpot Auto
- ObjectReference Property SAM_PlayerSideChoiceVisibilityRef Auto
- GlobalVariable Property SAM_MovingStoneCount Auto
- GlobalVariable Property SAM_IsPlaying Auto
- GlobalVariable Property SAM_WhoPlaying Auto
- ObjectReference Property SpotStone01 Auto
- ObjectReference Property SpotStone02 Auto
- ObjectReference Property SpotStone03 Auto
- ObjectReference Property SpotStone04 Auto
- ObjectReference Property SpotStone05 Auto
- ObjectReference Property SpotStone06 Auto
- ObjectReference Property SpotStone07 Auto
- ObjectReference Property SpotStone08 Auto
- ObjectReference Property SpotStone09 Auto
- ObjectReference Property SpotStone10 Auto
- ObjectReference Property SpotStone11 Auto
- ObjectReference Property SpotStone12 Auto
- ObjectReference Property SpotStone13 Auto
- ObjectReference Property SpotStone14 Auto
- ObjectReference Property House1 Auto
- ObjectReference Property House2 Auto
- ObjectReference Property SAM_BoardSoundRef Auto
- Message Property SAM_MancalaBoardEmptySlotMessage Auto
- Sound Property PHYDishWoodLSD Auto
- ObjectReference Property SAM_DestinationSlotSpot Auto
- ObjectReference Property SAM_DestinationSlot Auto
- ObjectReference Property SAM_DestinationSlotSpotRef01 Auto
- ObjectReference Property SAM_DestinationSlotSpotRef02 Auto
- ObjectReference Property SAM_DestinationSlotSpotRef03 Auto
- ObjectReference Property SAM_DestinationSlotSpotRef04 Auto
- ObjectReference Property SAM_DestinationSlotSpotRef05 Auto
- ObjectReference Property SAM_SlotExistingMarbles01 Auto
- ObjectReference Property SAM_SlotExistingMarbles02 Auto
- ObjectReference Property SAM_SlotExistingMarbles03 Auto
- ObjectReference Property SAM_SlotExistingMarbles04 Auto
- ObjectReference Property SAM_SlotExistingMarbles05 Auto
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement