コード例 #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.GetComponent <TimeChangeableObject>())
        {
            TimeChangeableObject target = other.gameObject.GetComponent <TimeChangeableObject>();
            if (isObjectHiddenByObstacle(target))
            {
                return;
            }

            GetComponentInParent <Player>().setTarget(target);
        }
        if (other.gameObject.tag == "ChillPo")
        {
            List <GameObject> GOList = new List <GameObject>();
            GOList.AddRange(GameObject.FindGameObjectsWithTag("ChillPo"));
            foreach (GameObject train in GOList)
            {
                Follower fol = train.GetComponent <Follower>();
                if (fol != null)
                {
                    fol.SlowTrain();
                }
            }
        }
    }
コード例 #2
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.GetComponent <TimeChangeableObject>())
        {
            TimeChangeableObject target = other.gameObject.GetComponent <TimeChangeableObject>();
            if (isObjectHiddenByObstacle(target))
            {
                return;
            }

            GetComponentInParent <Player>().setTarget(target);
        }
    }
コード例 #3
0
ファイル: Player.cs プロジェクト: rsludwikowski/Portfolio
    private void ImplementSlowOrHaste(string slowOrHaste, TimeChangeableObject Hitted)
    {
        switch (slowOrHaste)
        {
        case "slow":
            Hitted.slow();
            break;

        case "haste":
            Hitted.haste();
            break;
        }
    }
コード例 #4
0
    bool isObjectHiddenByObstacle(TimeChangeableObject target)
    {
        //float distanceToPlayer = Vector3.Distance(GetComponentInParent<TimeChangeableObject>().transform.position, target.TimeChangeableObjectBody.position);
        float distanceToPlayer = Vector3.Distance(transform.position, target.TimeChangeableObjectBody.position);

        // RaycastHit[] hits = Physics.RaycastAll(GetComponentInParent<TimeChangeableObject>().transform.position, target.TimeChangeableObjectBody.position - GetComponentInParent<TimeChangeableObject>().transform.position, distanceToPlayer);
        RaycastHit[] hits = Physics.RaycastAll(transform.position, target.TimeChangeableObjectBody.position - transform.position, distanceToPlayer);
        foreach (RaycastHit hit in hits)
        {
            // ignore the enemy's own colliders (and other enemies)
            if (hit.transform.tag == "Player")
            {
                continue;
            }

            // if anything other than the player is hit then it must be between the player and the enemy's eyes (since the player can only see as far as the player)
            if (hit.transform.tag != "TimeChangeableObject")
            {
                return(true);
            }
        }
        // if no objects were closer to the enemy than the player return false (player is not hidden by an object)
        return(false);
    }
コード例 #5
0
ファイル: Player.cs プロジェクト: rsludwikowski/Portfolio
 public void setTarget(TimeChangeableObject Target)
 {
     target = Target;
 }