Exemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     player     = MetaScript.getPlayer();
     spawnPoint = gameObject;
     canFire    = true;
     controls   = MetaScript.GetControls();
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        Vector3 tPos = MetaScript.getPlayer().transform.position;
        Vector3 pPos = transform.position;

        navComponent.enabled = true;
        //navComponent.SetDestination(target.transform.position);
        float distanceToTarget = Vector3.SqrMagnitude(tPos - pPos);

        if (distanceToTarget <= Mathf.Pow(followDistance, 2))
        {
            navComponent.isStopped = true;
        }
        else if (distanceToTarget >= Mathf.Pow(maxDist, 2))
        {
            navComponent.enabled = false;
            Vector3 updatePos = (pPos - tPos).normalized * maxDist + tPos;
            updatePos.y          = tPos.y;
            transform.position   = updatePos;
            navComponent.enabled = true;
        }
        else
        {
            navComponent.isStopped = false;
            navComponent.SetDestination(tPos);
        }
    }
Exemplo n.º 3
0
    private void getDest()
    {
        if (opponent != null)
        {
            opponent.SendMessage("stopTargeted", gameObject);
        }

        opponent = collect.findClosestTag("OwnedNPC", gameObject);
        if (opponent != null)
        {
            float oppDist    = (transform.position - opponent.transform.position).sqrMagnitude;
            float playerDist = (transform.position - MetaScript.getPlayer().transform.position).sqrMagnitude;
            if (playerDist < oppDist)
            {
                opponent = MetaScript.getPlayer();
            }
        }
        else
        {
            opponent = MetaScript.getPlayer();
        }
        if (opponent != null)
        {
            opponent.SendMessage("beingTargeted", gameObject);
        }
    }
Exemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     if (controls.keyDown(controls.Outpost) && canSend && buildingPrefabs[0].GetComponent <resourceCost>().canAfford())
     {
         if (MetaScript.getOPController().checkDistance(transform.position))
         {
             if (MetaScript.getOPController().canAddOutPost())
             {
                 // Build surrounding area to avoid nav issues
                 MetaScript.getPlayer().GetComponent <DynamicGeneration>().generateSurrounding(Chunk.getChunkPos(transform.position));
                 canSend = false;
                 buildingPrefabs[0].GetComponent <resourceCost>().purchase();
                 Instantiate(buildingPrefabsObjects[0], gameObject.transform.position, Quaternion.identity);
                 StartCoroutine(canSendTimer());
                 MetaScript.getOPController().addOutpost();
             }
             else
             {
                 Debug.Log("Already at the outpost limit");
             }
         }
         else
         {
             Debug.Log("Campfire too close to other campfire or TC");
         }
     }
 }
Exemplo n.º 5
0
 // Update is called once per frame
 void Update()
 {
     if (player == null)
     {
         player = MetaScript.getPlayer();
         Debug.Log("Building had to find player again");
     }
 }
Exemplo n.º 6
0
    void OnDisable()
    {
        // Unload navmesh and clear handle
        m_Instance.Remove();

        // Notify the player that this navmesh doesn't need to be checked
        MetaScript.getPlayer().SendMessage("RemResMesh", this);
    }
Exemplo n.º 7
0
    private void Start()
    {
        timer2 = timer;
        player = MetaScript.getPlayer();

        buildingCheck = player.GetComponent <InBuilding>();
        controls      = MetaScript.GetControls();
    }
Exemplo n.º 8
0
 public void recieveAction()
 {
     MetaScript.preTeleport();
     MetaScript.getPlayer().GetComponent <DynamicGeneration>().enabled = false;
     MetaScript.getPlayer().transform.position = new Vector3(entranceXPos, DEPTH, entranceZPos);
     MetaScript.getPlayer().GetComponent <InBuilding>().setPlayerInBuilding(true);
     MetaScript.postTeleport();
 }
Exemplo n.º 9
0
    void OnEnable()
    {
        // Construct and add navmesh
        m_NavMesh  = new NavMeshData();
        m_Instance = NavMesh.AddNavMeshData(m_NavMesh);
        if (m_Tracked == null)
        {
            m_Tracked = transform;
        }

        UpdateNavMesh(false);
        // Notify player to check this navmesh
        MetaScript.getPlayer().SendMessage("AddResMesh", this);
    }
Exemplo n.º 10
0
 // Use this for initialization
 void Start()
 {
     bg = new building_generator((int)gameObject.transform.position.x, (int)gameObject.transform.position.y, (int)gameObject.transform.position.z, gameObject, wall, door, floor);
     if (bg == null)
     {
         Debug.Log("The building_generator object is null.");
     }
     player = MetaScript.getPlayer();
     if (player == null)
     {
         Debug.Log("The player object is null.");
     }
     else
     {
         ps = player.GetComponentsInChildren <ParticleSystem>();
     }
 }
Exemplo n.º 11
0
    // Update is called once per frame
    void Update()
    {
        if (controls.keyDown(controls.TownPortal))
        {
            bool inBuilding = false;
            if (buildingCheck != null)
            {
                inBuilding = buildingCheck.getPlayerInBuilding();
            }

            if (MetaScript.getRes().hasResource(costType, resourceCost) && !inBuilding)
            {
                MetaScript.getRes().addResource(costType, -resourceCost);
                MetaScript.preTeleport();
                transform.parent.transform.position = MetaScript.getTownCenter().transform.position + new Vector3(0.5f, 0, -0.5f);
                MetaScript.postTeleport();
                MetaScript.Poof(MetaScript.getPlayer().transform.position);
            }
        }
    }
Exemplo n.º 12
0
 private void Start()
 {
     timer2 = timer;
     player = MetaScript.getPlayer().GetComponentInChildren <actor>().gameObject;
 }
Exemplo n.º 13
0
 // Use this for initialization
 void Start()
 {
     player            = MetaScript.getPlayer();
     gameOverText.text = " ";
     backToMenu.text   = " ";
 }
Exemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     player = MetaScript.getPlayer();
 }
Exemplo n.º 15
0
 void Start()
 {
     setHealth(MetaScript.getPlayer().GetComponent <Health> ());
     healthBar        = this.transform.GetChild(1).gameObject;
     healthNumberText = this.transform.GetChild(2).gameObject.GetComponent <Text> ();
 }
Exemplo n.º 16
0
 // Use this for initialization
 void Stop()
 {
     Controls.focused(true);
     MetaScript.getPlayer().GetComponent <Health>().isImmortal = true;
 }
Exemplo n.º 17
0
 // Use this for initialization
 void Start()
 {
     tc     = MetaScript.getTownCenter().transform.position;
     player = MetaScript.getPlayer();
 }