示例#1
0
    public override bool check(Controller c)
    {
        HermitCrab hc = State.cast <HermitCrab> (c);

        hc.doNullify();
        return(hc.updateStandDuration(Time.deltaTime));
    }
示例#2
0
    public override void perform(Controller c)
    {
        HermitCrab hc = State.cast <HermitCrab> (c);

        hc.GetComponent <PushBlock> ().disableMovement();
        hc.resetStandDuration();
    }
示例#3
0
        public CSeed(Controller c) : base(c)
        {
            HermitCrab h = State.cast <HermitCrab>(c);

            home          = h.home;
            sitDuration   = h.sitDuration;
            standDuration = h.standDuration;
            returnTimer   = h.returnTimer;
        }
示例#4
0
    public override bool check(Controller c)
    {
        HermitCrab hc = State.cast <HermitCrab> (c);

        if (hc.GetComponent <PushBlock> ()._beingPushed)
        {
            hc.setWasPushed(true);
            hc.resetSitDuration();
            return(false);
        }
        else
        {
            return(hc.updateSitDuration(Time.deltaTime) && hc.getStands());
        }
    }
示例#5
0
    public override void perform(Controller c)
    {
        HermitCrab hc = State.cast <HermitCrab> (c);

        source = c.GetComponent <AudioSource>();
        if (source != null)
        {
            source.Stop();
            source.loop = false;
            source.PlayOneShot(AudioLibrary.inst.hermitCrabDown, 1);
            Debug.Log("Sit Sound");
        }
        hc.GetComponent <PushBlock> ().enableMovement();
        hc.resetSitDuration();
    }
示例#6
0
    public override bool check(Controller c)
    {
        HermitCrab hc = State.cast <HermitCrab> (c);

        if (c.getMap() == null)
        {
            //not sure how you would get here without an Atlas, but okay. ナイスジョブ
            Debug.LogError(hc.name + " needs an Atlas!");
            return(false);
        }
        if (Vector2.Distance(c.transform.position, hc.getHome()) <= c.getSelf().getMovespeed() * Time.deltaTime)
        {
            c.transform.position = hc.getHome();
            return(true);
        }
        return(!hc.checkSitDuration());
    }
示例#7
0
    public override void perform(Controller c)
    {
        HermitCrab hc = State.cast <HermitCrab> (c);

        source = c.GetComponent <AudioSource>();

        if (hc.getWasPushed())
        {
            hc.setReturnTimerOnStand();
            if (source != null)
            {
                source.clip = AudioLibrary.inst.hermitCrabMoving;
                source.loop = true;
                source.Play();
                Debug.Log("Walk sound");
            }
        }
        else
        {
            hc.resetReturnTimer();
        }
    }
示例#8
0
    public override void perform(Controller c)
    {
        HermitCrab hc = State.cast <HermitCrab> (c);

        hc.doNullify();

        if (hc.updateReturnTimer(Time.deltaTime))
        {
            float totalDist = Vector2.Distance(c.transform.position, hc.getHome());
            bool  nearHome  = totalDist < c.getMap().cellDimension;

            Vector3 navPos = hc.transform.position;
            if (c.getMap() != null)
            {
                if (nearHome)
                {
                    navPos = hc.getHome();
                }
                else if (!c.currentPosition(out navPos))
                {
                    c.setPath(hc.getHome());
                }

                if (!nearHome)
                {
                    c.currentPosition(out navPos);
                }
            }
            else
            {
                Debug.LogError(c.name + " needs an Atlas!");
            }

            float dist     = Vector2.Distance(c.transform.position, navPos);
            float moveDist = c.getSelf().getMovespeed() * Time.deltaTime;
            if (moveDist > dist)
            {
                moveDist = dist;
            }

            //move
            Vector3 dir = navPos - c.transform.position;
            c.transform.Translate(dir.normalized * moveDist, Space.World);

            //determine facing sprite using dir (defined above)
            //TODO crab walking animation here
            if (dir != Vector3.zero)
            {
                Quaternion qdir = Quaternion.LookRotation(dir, Vector3.back);
                if (qdir.eulerAngles.z > 315 || qdir.eulerAngles.z < 45)
                {
                    //up
                    hc.GetComponent <Animator> ().SetInteger("Direction", 1);
                }
                if (qdir.eulerAngles.z > 45 && qdir.eulerAngles.z < 135)
                {
                    //left
                    hc.GetComponent <Animator> ().SetInteger("Direction", 4);
                }
                if (qdir.eulerAngles.z > 135 && qdir.eulerAngles.z < 225)
                {
                    //down
                    hc.GetComponent <Animator> ().SetInteger("Direction", 3);
                }
                if (qdir.eulerAngles.z > 225 && qdir.eulerAngles.z < 315)
                {
                    //right
                    hc.GetComponent <Animator> ().SetInteger("Direction", 2);
                }
            }

            //if near the next point in the path, look ahead
            if (c.getMap() != null && dist < c.getMap().cellDimension / 1.7f)
            {
                c.nextPosition(out navPos);
            }
        }
    }