public override void SupportStar(StarElement friendStar) { if (CanSupport == false) { return; } else { CanSupport = false; coldTime = Random.Range(2.0f, 6.0f); } int randomTroopNum = GetRandomTroopNum(); if (randomTroopNum > 0) { Transform currentBornPos = m_bornPoint[Random.Range(0, m_bornPoint.Length)]; GameObject newShip = Instantiate(m_shipPrefab) as GameObject; if (newShip) { ShipElement shipElement = newShip.GetComponent <ShipElement>(); shipElement.m_StarFrom = this; shipElement.m_StarTo = friendStar; shipElement.m_ShipSize = (ShipElement.ShipSize)randomTroopNum; shipElement.m_ShipTroopNum = randomTroopNum; shipElement.m_FlySpeed = shipElement.m_SurrondSpeed = 4 + Random.Range(0.0f, 5.0f); newShip.transform.position = currentBornPos.position; ((TestShip)shipElement).SetShipScaleBySize(); this.m_TroopNum -= randomTroopNum; } } ResetSize(); }
public void FillSocket(ShipElement shipElement) { toReactivate.GetComponent <Repairable>().SpawnVersion(shipElement.GetComponent <Repairable>().currentState); Destroy(shipElement.gameObject); toReactivate.SetActive(true); gameObject.SetActive(false); SoundManagerScript.instance.PlayOneShotSound(SoundManagerScript.AudioClips.ShipConnectPiece); }
private bool CanBeginSurrond(ShipElement ship, StarElement otherStar) { Vector3 crossV1 = otherStar.transform.position - ship.transform.position; Vector3 crossV2 = new Vector3(crossV1.x, crossV1.y + 1, crossV1.z);//ship.transform.up; Vector3 crossResult = Vector3.Cross(crossV1, crossV2) * m_Ship.m_SurrondDirection; Vector3 plane2TargetDirection = m_Ship.m_StarTo.transform.position - m_Ship.transform.position; return(!CanResumeMove(plane2TargetDirection, crossResult)); }
public override void SupportStar(StarElement friendStar, int supportNum) { int troopNum = supportNum; if (troopNum > 0) { Transform currentBornPos = m_bornPoint[Random.Range(0, m_bornPoint.Length)]; GameObject newShip = Instantiate(m_shipPrefab) as GameObject; if (newShip) { ShipElement shipElement = newShip.GetComponent <ShipElement>(); shipElement.m_StarFrom = this; shipElement.m_StarTo = friendStar; shipElement.m_ShipSize = GetSizeByNum(troopNum); shipElement.m_ShipTroopNum = troopNum; shipElement.m_FlySpeed = shipElement.m_SurrondSpeed = 4 + Random.Range(0.0f, 5.0f); newShip.transform.position = currentBornPos.position; ((TestShip)shipElement).SetShipScaleBySize(); this.m_TroopNum -= troopNum; } } ResetSize(); }
void Update() { Interactable hoveredInteractable = null; if (smallInteractableInRange != null) { hoveredInteractable = smallInteractableInRange; } else { bool foundInteractable = false; foreach (Transform raycastSource in raycastSources) { foreach (RaycastHit hit in Physics.RaycastAll(raycastSource.position, raycastSource.forward, grabRange, grabLayerMask)) { hoveredInteractable = hit.collider.GetComponent <Interactable>(); if (hoveredInteractable != null && (grabbedObject == null || hoveredInteractable.transform != grabbedObject.transform)) { foundInteractable = true; break; } } if (foundInteractable) { break; } } } if (hoveredInteractable != null) { if (objectInRange != hoveredInteractable) { if (objectInRange != null) { objectInRange.SetHilight(false); } objectInRange = hoveredInteractable; objectInRange.SetHilight(true); } } else if (objectInRange != null) { objectInRange.SetHilight(false); objectInRange = null; } if (Input.GetButtonDown("Interact" + playerIndex)) { if (grabbedObject == null) { if (objectInRange != null) { objectInRange.OnInteractionBy(this, toolHandler.usedToolType); } } else { if (objectInRange != null) { ShipSocket socket = objectInRange.GetComponent <ShipSocket>(); ShipElement element = grabbedObject.GetComponent <ShipElement>(); if (element != null && socket != null && element.shipPart == socket.shipPart) { socket.FillSocket(element); } } grabbedObject.OnReleased(this); grabbedObject = null; } } if (Input.GetButtonDown("Drop" + playerIndex)) { if (toolHandler.hasTool) { toolHandler.DropTool(); } if (grabbedObject == null) { } } }
public ShipFlyState(StateManager stateManager, ShipElement ship) : base(stateManager, ship) { }
public ShipStateBase(StateManager stateManager, ShipElement ship) { this.m_StateManager = stateManager; this.m_Ship = ship; }
public StateManager(ShipElement ship) { m_ShipState = new ShipBornState(this, ship); }
public ShipSurrondState(StateManager stateManager, ShipElement ship) : base(stateManager, ship) { }