Exemplo n.º 1
0
    void OnLand(Landable landable, Vector3 landPoint)
    {
        landable.OnSeedHit(this);

        landable.Infest(landPoint, InfestOnLanding);

        var plant = Instantiate <CannonPlant> (GrowOnLanding);

        plant.Attach(landable, landPoint, transform.forward);

        if (!Dummy)
        {
            PlayerControl.SceneInstance.ActiveControllable = plant;
        }

        var plantParticles = GetComponentInChildren <ParticleSystem> ();

        plantParticles.transform.SetParent(landable.transform);
        plantParticles.Play();
        Destroy(plantParticles, 2f);

        var trail = GetComponentInChildren <TrailRenderer> ();

        trail.transform.SetParent(null);
        Destroy(trail, trail.time);

        Destroy(gameObject);
    }
Exemplo n.º 2
0
 public void AddShip(Landable ship, int index)
 {
     GameObject buttonObject = NGUITools.AddChild(shipsList.gameObject, shipButtonPrefab);
     //panel.Refresh();
     Vector3 buttonObjectPosition = new Vector3(70 * index, 0 , 1);
     buttonObject.transform.localPosition = buttonObjectPosition;
     //BroadcastMessage("CheckParent", SendMessageOptions.DontRequireReceiver);
     ShipButton button = buttonObject.transform.Find("ShipButtonWidget").GetComponent<ShipButton>();
     button.Setup(ship, planet);
 }
Exemplo n.º 3
0
    public void Attach(Landable to, Vector3 location, Vector3 forward)
    {
        AttachedTo = to;

        transform.position = location;

        Vector3 outward         = to.transform.InverseTransformPoint(location) - to.Collision.center;
        Vector3 parallelForward = Vector3.RotateTowards(outward, forward, 90f * Mathf.Deg2Rad, 0f);

        Debug.DrawRay(location, parallelForward * 5f, Color.green, 10f);
        Debug.DrawRay(location, outward * 5f, Color.cyan, 10f);

        transform.rotation = Quaternion.LookRotation(parallelForward, outward);
        transform.SetParent(to.transform);
    }
        /// <summary>
        /// ViewModel subroutine for rotating the board
        /// </summary>
        /// <param name="_sender"></param>
        private async void _RotateBoardAsync(object _sender)
        {
            // Use BoardScale bindings to create a popping animation
            for (double i = 1.05; i < 1.10; i += 0.01)
            {
                BoardScale            = i;
                RotateButtonRotation -= 9;
                await Task.Delay(10);
            }
            // Transform the board, roatating the properties
            switch (BoardColumnConverter.BoardRotation)
            {
            case BoardRotateMode.Thrice:
                BoardColumnConverter.BoardRotation = BoardRotateMode.Normal;
                break;

            default:
                BoardColumnConverter.BoardRotation += 10;
                break;
            }
            foreach (Location Landable in Handler.Board)
            {
                if (Landable != null)
                {
                    Landable.OnPropertyChanged("Position");
                }
            }
            // Use BoardScale bindings to finish the popping animation
            for (double i = 1.10; i > 1.05; i -= 0.01)
            {
                BoardScale            = i;
                RotateButtonRotation -= 9;
                await Task.Delay(10);
            }
            BoardScale = 1.05;
            if (RotateButtonRotation <= 0)
            {
                RotateButtonRotation = 360;
            }
        }
Exemplo n.º 5
0
    public void FlyToTree(PeachTreeLandingPtsCtrler peachTree, bool scattered = true)
    {
        if (peachTree == perchingTree)
        {
            return;
        }

        foreach (Landable landable in perchingTree.landablePts)
        {
            landable.ReleaseAll();
        }

        perchingTree = peachTree;

        if (scattered)
        {
            cohesionFactor = -Mathf.Abs(cohesionFactor);
        }
        else
        {
            cohesionFactor = Mathf.Abs(cohesionFactor);
        }

        foreach (BoidFlocking boid in boids)
        {
            Landable landable = peachTree.GetOneLandablePt();
            if (landable == null)
            {
                Debug.Log("not enough landing pts QAQ");
                break;
            }
            landable.TargetBy(boid);
            boid.EnterState(BoidFlocking.State.flocking);
        }

        if (cohesionFactor < 0)
        {
            Invoke("RecoverCoherent", 1);
        }
    }
    void AddLandingPt(string name, Vector3 pos)
    {
        Transform pt = Instantiate(placeholderPrefab, pos, Quaternion.identity);

        pt.parent           = ptsRoot;
        pt.localEulerAngles = new Vector3(0, Random.Range(0, 360), 0);

        if (putTestingButterfly)
        {
            GameObject butterflyObj = Instantiate(testButterfly, Vector3.zero, Quaternion.identity);
            butterflyObj.transform.parent   = pt;
            butterflyObj.transform.position = pt.position;
            butterflyObj.transform.rotation = pt.rotation;
        }

        Landable landable = pt.GetComponent <Landable>();

        if (landable != null)
        {
            landablePts.Add(landable);
        }
    }
Exemplo n.º 7
0
    public void EnterState(State state)
    {
        if (state == curState)
        {
            return;
        }

        preState = curState;
        curState = state;

        if (curState == State.perching)
        {
            animator.SetBool("isIdle", true);
            SetAnimSpeed(0);
            if (isAvoiding)
            {
                ChangeAvoidMode(false);
            }
            rigid.isKinematic = true;
            rigid.velocity    = Vector3.zero;
            landingPt         = target.GetComponent <Landable>();
        }
        else if (curState == State.landing)
        {
        }
        else if (curState == State.approaching)
        {
            ChangeAvoidMode(false);
        }
        else if (curState == State.flocking)
        {
            animator.SetBool("isIdle", false);
            rigid.isKinematic = false;
            ChangeAvoidMode(true);
        }
    }
Exemplo n.º 8
0
 /// <summary>
 /// Initialize this button.
 /// </summary>
 public void Setup(Landable landable, Planet thePlanet)
 {
     planet = thePlanet;
     landedShip = landable;
 }
Exemplo n.º 9
0
 public void NotifyLanding(Landable landingObject)
 {
     Game.gui.planetMenu.mainColonyPanel.GetComponent<ColonyPanel>().AddShip(landingObject);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Signal to launch the given landable
 /// </summary>
 /// <returns>
 /// True if allowed to launch
 /// </returns>
 public bool RequestLaunch(Landable landedCraft)
 {
     landedCraft.Launch( transform.position + transform.localScale + landedCraft.transform.lossyScale);
     return true; //TODO: Would we turn down a launch?
 }
Exemplo n.º 11
0
    /// <summary>
    /// Check whether given Landable can land here.
    /// </summary>
    /// <returns>
    /// True if landing permission granted
    /// </returns>
    public bool RequestLanding(Landable landingObject)
    {
        Ship landingShip = landingObject.GetComponent<Ship>();
        if(landingShip == null)
            return false;

        ShipData data = landingShip.GetShipData();
        if(data == null)
            return false;

        return true;
    }
Exemplo n.º 12
0
 /// <summary>
 /// Signal to launch the given landable
 /// </summary>
 /// <returns>
 /// True if allowed to launch
 /// </returns>
 public bool RequestLaunch(Landable landedCraft)
 {
     landedCraft.Launch( transform.position + transform.localScale + landedCraft.transform.lossyScale);
     return true;
 }