コード例 #1
0
    private void castARay(int damageToInduce, float rayDistance)
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, rayDistance))
        {
            if (hit.collider.tag == "Player")
            {
                OurMinifigController hit_player = hit.collider.gameObject.GetComponent <OurMinifigController>();
                hit_player.damage += damageToInduce;
                Vector3 hit_direction = hit_player.transform.position - transform.position;
                hit_direction.x  = 0f; // do not change x position
                hit_direction.y += 1f; // make the hit player fly slightly upwards
                if (hit_direction.z > 0)
                {
                    hit_direction.z = 1f;
                }
                else
                {
                    hit_direction.z = -1f;
                }
                hit_direction.Normalize();
                float dmg_scale = (hit_player.damage + 10) * 0.01f;
                hit_player._knockback += hit_direction * dmg_scale;
            }
        }
    }
コード例 #2
0
ファイル: AIAgentR.cs プロジェクト: pauzii/IGD2021
    public void chooseBehaviour()
    {
        //Choose player to follow
        (int[] platforms, bool[] died) = gameManager.getGameState();
        List <int> notDeadPlayers = new List <int> {
        };

        for (int i = 0; i < 4; ++i)
        {
            if (i == id || died[i])
            {
                continue;
            }
            notDeadPlayers.Add(i);
        }
        int randomChoice = UnityEngine.Random.Range(0, notDeadPlayers.Count);

        target = gameManager.getPlayer(randomChoice);
        animator.SetInteger("platform", target.getPlatform());
    }