예제 #1
0
 void Start()
 {
     if (!Debug.isDebugBuild)
     {
         GameObject.Find("DebugUI").SetActive(false);
     }
     Follow = GetComponent <FollowScript>();
 }
예제 #2
0
    //Variables that can be set by the user


    //Implement abstract properties

    /*public override float Range {
     *  get { return 5; }
     * }
     *
     * public override float Cooldown {
     *  get { return 0.5f; }
     * }
     *
     * public override float AnimationCooldown {
     *  get { return 0.1f; }
     * }
     *
     * public override int SpawnAmount {
     *  get { return 1; }
     * }
     *
     * public override float DamageAmount {
     *  get { return 2;}
     *
     * }*/

    protected override void Awake()
    {
        base.Awake();
        //Get references
        bc = GetComponent <BoxCollider2D>();
        lr = GetComponent <LineRenderer>();
        fs = GetComponent <FollowScript>();
    }
예제 #3
0
    void Update()
    {
        if (healthBar == null && (tower.GetHealth() < tower.GetMaxHealth() || Game.GetSelectedTower() == tower))
        {
            healthBar = Instantiate(healthBarPrefab, Game.progressCanvas.transform);
            healthBar.GetComponent <HealthScript>().healthable = tower;
        }
        else if (tower.GetHealth() == tower.GetMaxHealth() && Game.GetSelectedTower() != tower)
        {
            Destroy(healthBar);
            healthBar = null;
        }

        if (tower.GetHealth() <= 0)
        {
            if (Game.GetSelectedTower() == tower)
            {
                Game.SelectTower(null);
            }

            Destroy(healthBar);

            tile.Hold(null);
            tile.SetUsed(false);

            GameObject.Destroy(gameObject);
        }

        if (tower != null)
        {
            if (!run)
            {
                GameObject model;
                model = Instantiate(tower.GetModel(), new Vector3(transform.position.x, transform.position.y + 2.5f, transform.position.z), transform.rotation);
                model.transform.SetParent(transform);

                FollowScript fs = model.GetComponentInChildren <FollowScript>();
                if (fs != null)
                {
                    tower.follow = fs.transform;
                }
                run = true;
            }
        }

        if (selectRenderer != null)
        {
            if (Game.GetSelectedTower() == tower)
            {
                selectRenderer.enabled = true;
            }
            else
            {
                selectRenderer.enabled = false;
            }
        }
    }
예제 #4
0
    bool hasFollowScript(GameObject givenNPC)
    {
        bool         result = false;
        FollowScript script = givenNPC.GetComponent <FollowScript> ();

        if (script != null)
        {
            result = true;
        }
        return(result);
    }
    public void Respawn()
    {
        FollowScript follow = FindObjectOfType <FollowScript> ().GetComponent <FollowScript> ();

        follow.ResetCamera();

        transform.position = originalPos;
        transform.rotation = originalRot;
        foreach (Collider c in gameObject.GetComponents <Collider>())
        {
            c.enabled = true;
        }
        gameObject.GetComponent <SpaceShipController> ().enabled = true;
    }
예제 #6
0
    public Part CreateCameraPoint(List <Vector3> nodes)
    {
        Vector3 node0 = nodes[0];

        Vector3    position = node0;
        Quaternion rotation = Quaternion.identity;

        GameObject cameraPoint;

        cameraPoint = Instantiate(cameraPointPrefab, position, rotation);

        FollowScript followScript = theCamera.gameObject.GetComponent <FollowScript>();

        followScript.target = cameraPoint.transform;

        Part part = new Part(cameraPoint, nodes);

        return(part);
    }
예제 #7
0
    void addCorrespondingScript(GameObject npc, NPC npcObject, int roomIndex)
    {
        AggressionState npcAggressionState = npcObject.aggressionState;

        if (npcAggressionState.isLook())
        {
            npc.AddComponent <LookScript> ();
        }
        else if (npcAggressionState.isFollow())
        {
            FollowScript follow = npc.AddComponent <FollowScript> ();
            follow.roomIndex = roomIndex;
        }
        else if (npcAggressionState.isAttack())
        {
            AttackScript attack = npc.AddComponent <AttackScript> ();
            attack.roomIndex = roomIndex;
        }
        else
        {
            Debug.Log("NPC's current state has no script association");
        }
    }
예제 #8
0
    void clearFollowPatrol(GameObject npc)
    {
        FollowScript follow = npc.GetComponent <FollowScript> ();

        follow.clearData();
    }
 // Use this for initialization
 void Start()
 {
     followScript = GetComponent <FollowScript>();
 }
예제 #10
0
    // Use this for initialization
    void Start()
    {
        int resolution = length / nbrOfSegments;

        for (int i = 0; i < nbrOfSegments; i++)
        {
            Transform aNode = Instantiate(Node, new Vector3(0, -1f, 0), Quaternion.identity);
            //Node.SetParent(this.transform);
            aNode.parent = this.transform;
        }

        int childCount = this.transform.childCount;

        for (int i = 0; i < childCount; i++)
        {
            Transform node = this.transform.GetChild(i);
            //Connects nodes to previous nodes
            if (i == 0)
            {
                //connect to base
                node.GetComponent <AdvancedRope>().whatTheRopeIsConnectedTo = node.GetChild(0);
                node.GetComponent <AdvancedRope>().whatIsHangingFromTheRope = baseConnector;
            }
            else
            {
                Transform prevNode = this.transform.GetChild(i - 1);

                Transform anchor = node.GetChild(0);

                node.GetComponent <AdvancedRope>().whatTheRopeIsConnectedTo = anchor;
                node.GetComponent <AdvancedRope>().whatIsHangingFromTheRope = prevNode.GetChild(0);
            }

            //Connect the anchors to the following nodes
            if (i < 1)
            {
                baseConnector.GetComponent <SpringJoint>().connectedBody = node.GetChild(0).GetComponent <Rigidbody>();
                Transform nextNode      = this.transform.GetChild(i + 1);
                Rigidbody nextRigidbody = nextNode.GetChild(0).GetComponent <Rigidbody>();
                node.GetChild(0).GetComponent <SpringJoint>().connectedBody = nextRigidbody;
            }
            else if (i == childCount - 1)
            {
                //connect last node to end hinge
                node.transform.position = endConnector.transform.position;

                Rigidbody rigidbody = node.GetChild(0).GetComponent <Rigidbody>();
                rigidbody.transform.position = endConnector.transform.position;
                rigidbody.isKinematic        = true;

                rigidbody = endConnector.GetComponent <Rigidbody>();
                node.GetChild(0).GetComponent <SpringJoint>().connectedBody = rigidbody;
                rigidbody.isKinematic = true;


                FollowScript fs = node.GetChild(0).gameObject.AddComponent <FollowScript>();
                fs.followTransform = endConnector;
            }
            else
            {
                Transform nextNode      = this.transform.GetChild(i + 1);
                Rigidbody nextRigidbody = nextNode.GetChild(0).GetComponent <Rigidbody>();
                node.GetChild(0).GetComponent <SpringJoint>().connectedBody = nextRigidbody;
            }
            if (node != null)
            {
                SpringJoint sj = node.GetChild(0).GetComponent <SpringJoint>();
                sj.enableCollision = false;
            }
        }
    }