コード例 #1
0
ファイル: AttackingMob.cs プロジェクト: duiker2/Rougue
    void Start()
    {
        InitializeEntity();
        AutoTarget = new AstralProjection(gameObject);

        canAttack = true;
        if (attackingg == null)
        {
            attackingg = GameObject.FindGameObjectWithTag("Player");
            attacking  = attackingg.GetComponent <Entities>();
        }

        mapgen           = GameObject.FindGameObjectWithTag("MapGen").GetComponent <MakeMap>();
        initFloor        = mapgen.DungeonFloor;
        ai               = new MovementAI(mapgen.currentFloor());
        isWandering      = true;
        isBlindlyChasing = false;

        /*
         * path = ai.getPath (gameObject.transform.position, attackingg.transform.position);
         * ai.currentNode = path.pop ();
         */
    }
コード例 #2
0
ファイル: AttackingMob.cs プロジェクト: duiker2/Rougue
    void FixedUpdate()
    {
        ai.fpscounter++;
        aidirection = attackingg.transform.position - gameObject.transform.position;

        RaycastHit2D hit = Physics2D.Raycast(gameObject.transform.position, aidirection, 12.0f, Wall);

        if (hit.collider != null && hit.collider.tag == "Player")
        {
            visible = true;
        }
        else
        {
            visible = false;
        }

        if (visible)
        {
            if (getDistance(attackingg) < 10.0f)
            {
                this.setDirection(aidirection);
                Move();
                isBlindlyChasing = false; //name innacurate because of this, but #YOLO
            }
            else
            {
                isBlindlyChasing = true;
            }
            if (isWandering && getDistance(attackingg) >= 10.0f)
            {
                actuallyRePath(attackingg.transform.position);
            }

            isWandering  = false;
            lastTimeSeen = Time.time;
        }
        else if (!visible && (Time.time - lastTimeSeen < chaseTimeOut))
        {
            isBlindlyChasing = true;
            isWandering      = false;
        }
        else
        {
            if (isBlindlyChasing)
            {
                actuallyRePath(attackingg.transform.position);
            }
            isWandering      = true;
            isBlindlyChasing = false;
        }



        if (isWandering)
        {
            if (ai.currentNode == null)
            {
                eTile[,] map = mapgen.currentFloor();
                Location randomPlace;
                do
                {
                    randomPlace = new Location(Random.Range(0, map.GetLength(0)), Random.Range(0, map.GetLength(1)));
                }while (map[randomPlace.x, randomPlace.y] != eTile.Floor);

                randomTarget = new Vector3(randomPlace.x, randomPlace.y, 0);

                PathFindTowards(randomTarget);
            }
            else
            {
                PathFindTowards(randomTarget);
            }
        }

        if (isBlindlyChasing)
        {
            PathFindTowards(attackingg.transform.position);
        }



        if (name.Equals("Ghost") && getDistance(attackingg) < 60 && GetComponent <Status>().see)
        {
            //if (getDistance (attackingg) < 60 && GetComponent<Status>().see) {
            AutoTarget.cast(attackingg);
            //Debug.Log ("123");
            //Debug.Log(attackingg.tag);
        }
    }