Beispiel #1
0
    public override void Enter()
    {
        FireSlimeAI fireSlimeAI = (FireSlimeAI)GetAI();
        FireSlime   fireSlime   = (FireSlime)fireSlimeAI.getCharacter();

        attackRange = fireSlime.getAttr().getAttackRange();
    }
Beispiel #2
0
    public override void Enter()
    {
        base.Enter();
        FireSlimeAI fireSlimeAI = (FireSlimeAI)GetAI();
        FireSlime   fireSlime   = (FireSlime)fireSlimeAI.getCharacter();
        GameObject  myBody      = fireSlime.GetGameObject();

        if (childrenStates.Count == 0)
        {
            MoveToEnemyState_FireSlime moveToEnemyState = fireSlimeAI.GetMoveToEnemyState();
            childrenStates.Add(moveToEnemyState);
        }
    }
Beispiel #3
0
    public override State Update()
    {
        FireSlimeAI fireSlimeAI = (FireSlimeAI)GetAI();
        FireSlime   fireSlime   = (FireSlime)fireSlimeAI.getCharacter();
        GameObject  myBody      = fireSlime.GetGameObject();

        if (Vector3.Distance(myBody.transform.position, fireSlime.currentTarget.transform.position) < attackRange)
        {
            return(State.SUCESSED);
        }

        return(State.FAILED);
    }
Beispiel #4
0
    public override void Enter()
    {
        base.Enter();
        FireSlimeAI fireSlimeAI = (FireSlimeAI)GetAI();
        FireSlime   fireSlime   = (FireSlime)fireSlimeAI.getCharacter();
        GameObject  myBody      = fireSlime.GetGameObject();

        if (childrenStates.Count == 0)
        {
            LaunchFusedLaserState_FireSlime launchFusedLaserState = fireSlimeAI.GetLaunchFusedLaserState();
            childrenStates.Add(launchFusedLaserState);
            launchFusedLaserState.currentState = State.NONE;
        }
    }
Beispiel #5
0
    public override void Enter()
    {
        FireSlimeAI fireSlimeAI = (FireSlimeAI)GetAI();
        FireSlime   fireSlime   = (FireSlime)fireSlimeAI.getCharacter();
        GameObject  myBody      = fireSlime.GetGameObject();

        attackRange        = fireSlime.getAttr().getAttackRange();
        attackRate         = fireSlime.getAttr().getAttackRate();
        fusedLaser         = fireSlime.GetFusedLaser();
        currentAttackRate  = 0;
        currentRecoverTime = 0;
        currentDuring      = fireDuring;
        count  = 3;
        isFire = false;
    }
Beispiel #6
0
    public override State Update()
    {
        FireSlimeAI fireSlimeAI = (FireSlimeAI)GetAI();
        FireSlime   fireSlime   = (FireSlime)fireSlimeAI.getCharacter();
        GameObject  myBody      = fireSlime.GetGameObject();

        if (currentAttackRate < attackRate)
        {
            currentAttackRate += Time.deltaTime;
        }
        else
        {
            if (!isFire)
            {
                float   angle = Vector3.Angle(myBody.GetComponent <FireSlimeBody>().FirePostion.up, (fireSlime.currentTarget.transform.position - myBody.GetComponent <FireSlimeBody>().FirePostion.position).normalized);
                Vector3 cross = Vector3.Cross(myBody.GetComponent <FireSlimeBody>().FirePostion.up, (fireSlime.currentTarget.transform.position - myBody.GetComponent <FireSlimeBody>().FirePostion.position).normalized);
                angle *= Vector3.Dot(myBody.GetComponent <FireSlimeBody>().FirePostion.forward, cross.normalized);
                if (currentDuring >= fireDuring)
                {
                    GameObject iFusedLaser = Object.Instantiate(fusedLaser, myBody.GetComponent <FireSlimeBody>().FirePostion.position, Quaternion.identity);
                    iFusedLaser.transform.localRotation *= Quaternion.Euler(0, 0, angle);
                    iFusedLaser.GetComponent <Rigidbody2D>().velocity = iFusedLaser.transform.up * fuseLaserSpeed * Time.deltaTime;
                    count--;
                    currentDuring = 0;
                }
                currentDuring += Time.deltaTime;
                if (count <= 0)
                {
                    isFire = true;
                }
            }
            else
            {
                if (currentRecoverTime < recovetTime)
                {
                    currentRecoverTime += Time.deltaTime;
                }
                else
                {
                    currentRecoverTime = 0;

                    return(State.SUCESSED);
                }
            }
        }
        return(State.RUNNING);
    }
Beispiel #7
0
    // Use this for initialization
    void Start()
    {
        for (int i = 0; i < fireSlimeBodies.Count; i++)
        {
            FireSlime fireSlime = new FireSlime(fireSlimeBodies[i], new FireSlimeAI(), new FireSlimeAttr(30, 5, 300, 0.5f, 8, new FireSlime1AtrrStrategy()), fusedLaser);
            fireSlimeBodies[i].SetActive(false);
            remainEnemys.Add(fireSlime);
        }

        for (int i = 0; i < fireSlime1Bodies.Count; i++)
        {
            FireSlime1 fireSlime1 = new FireSlime1(fireSlime1Bodies[i], new FireSlime1AI(), new FireSlimeAttr(30, 10, 300, 1f, 10, new FireSlime1AtrrStrategy()), meltedBomb);
            remainEnemys.Add(fireSlime1);
            fireSlime1Bodies[i].SetActive(false);
        }

        for (int i = 0; i < fireSlime2Bodies.Count; i++)
        {
            FireSlime2 fireSlime2 = new FireSlime2(fireSlime2Bodies[i], new FireSlime2AI(), new FireSlime2Attr(15, 5, 350, 0.4f, 8, new FireSlime2AttrStrategy()), iFire, rushFire);
            remainEnemys.Add(fireSlime2);
            fireSlime2Bodies[i].SetActive(false);
        }
        //InitEnemys();

        inDoor.SetActive(true);
        inDoor.GetComponent <SpriteRenderer>().sprite = CloseDoorSprite;

        inDoor.GetComponent <InDoor_FireSlimeScene>().SetRoom(this);
        outDoor.SetActive(true);
        outDoor.tag   = "Wall";
        outDoor.layer = LayerMask.NameToLayer("Wall");
        outDoor.GetComponent <SpriteRenderer>().sprite = CloseDoorSprite;

        for (int i = 0; i < prePos.Length; i++)
        {
            prePos[i] = -1;
        }

        for (int i = 0; i < spawnPostions.Count; i++)
        {
            GameObject iTarget = Instantiate(target, spawnPostions[i].transform.position, Quaternion.identity);
            targets.Add(iTarget);
        }
    }
Beispiel #8
0
    public override State Update()
    {
        FireSlimeAI fireSlimeAI = (FireSlimeAI)GetAI();
        FireSlime   fireSlime   = (FireSlime)fireSlimeAI.getCharacter();
        GameObject  myBody      = fireSlime.GetGameObject();

        float distance = Vector3.Distance(myBody.transform.position, fireSlime.currentTarget.transform.position);

        //如果有目标在视野内,则移动向目标,直到可以攻击到目标
        if (distance < fireSlime.getAttr().getAttackRange())
        {
            myBody.GetComponent <Rigidbody2D>().velocity = Vector3.zero;
            return(State.SUCESSED);
        }

        Vector3 dir = (fireSlime.currentTarget.transform.position - myBody.transform.position).normalized;

        myBody.GetComponent <Rigidbody2D>().velocity = dir * GetAI().getCharacter().getAttr().getSpeed() * Time.deltaTime;

        return(State.RUNNING);;
    }
Beispiel #9
0
    public override State Update()
    {
        FireSlimeAI fireSlimeAI = (FireSlimeAI)GetAI();
        FireSlime   fireSlime   = (FireSlime)fireSlimeAI.getCharacter();
        GameObject  myBody      = fireSlime.GetGameObject();

        if (fireSlime.currentTarget != null)
        {
            return(State.SUCESSED);
        }

        fireSlime.targets = Physics2D.OverlapCircleAll(myBody.transform.position, eyeViewDistance, LayerMask.GetMask("Player"));
        Collider2D[] targets = fireSlime.targets;

        if (targets != null && targets.Length > 0)
        {
            fireSlime.currentTarget = targets[0];
            return(State.SUCESSED);
        }
        return(State.FAILED);
    }
Beispiel #10
0
 public void SetCharacter(FireSlime fireSlime)
 {
     myCharacter = fireSlime;
 }