예제 #1
0
    public IEnumerator TransformAI(Vector3 transformation, AiDirection directionState, float yRotation, float zRotation)
    {
        transforming = true;                                            //Needed for animation
        DisableAiFunctionality();
        aiDirection = directionState;                                   //Changing directionState before transforming in order to too shoot new correct collision rays.
        ParticleSystem particleEffect = gameObject.transform.GetChild(1).GetChild(0).GetComponent <ParticleSystem>();

        particleEffect.Play();
        animator.SetTrigger("goDown");                                  //animate go down
        yield return(new WaitForSeconds(0.5f));

        if (spriteMask != null)
        {
            spriteMask.enabled = false;
        }

        particleEffect.Stop();
        transform.Translate(transformation);                    //translate splace
        transform.Rotate(0f, yRotation, zRotation);             //rotate 180 on y-axis
        yield return(new WaitForSeconds(0.2f));

        animator.SetTrigger("goUp");                                    //animate go up

        if (spriteMask != null)
        {
            spriteMask.enabled = true;
        }

        particleEffect.Play();
        yield return(new WaitForSeconds(0.8f));

        EnableAiFunctionality();
        particleEffect.Stop();
        transforming = false;
    }
예제 #2
0
    //Move this to AiHandler - it makes no sense to have it in AiPatrolling.
    public IEnumerator ResetAi()
    {
        if (co == null)
        {
            yield return(new WaitForEndOfFrame());
        }
        else
        {
            StopCoroutine(co);
        }
        DisableAiFunctionality();
        if (animator != null)
        {
            animator.ResetTrigger("goDown");            //stopping Animation
            animator.ResetTrigger("goUp");              //stopping Animation
        }

        yield return(new WaitForEndOfFrame());

        transform.position = startPosition;
        transform.rotation = startRotation;
        aiDirection        = startDirection;
        if (grumpyScript != null)
        {
            grumpyScript.grumpy = AiGrumpy.Grumpy.Relaxed;
        }
        if (aiHandler.neutralised)
        {
            Debug.Log("Hostalize");
            aiHandler.neutralised = false;
            //aiHandler.behaviour = AiBehaviour.Patrol;
            aiHandler.HostalizseAI();
        }
        aiHandler.behaviour = AiBehaviour.Patrol;
        yield return(new WaitForEndOfFrame());

        transforming = false;
        EnableAiFunctionality();
        InitiateAi();
        if (flipAtStart)
        {
            faceingLeft = false;
        }
    }
예제 #3
0
    void Start()
    {
        startPosition  = transform.position;
        startRotation  = transform.rotation;
        startDirection = aiDirection;
        startSpeed     = speed;

        isMoving     = true;
        shootRays    = true;
        canTransform = true;
        isMimic      = (mimic)?true:false;
        animator     = this.transform.GetComponentInChildren <Animator>();
        myTrans      = this.transform;
        myBoxCol     = this.GetComponent <BoxCollider2D>();
        grumpyScript = (GetComponent <AiGrumpy>() == null)?null:GetComponent <AiGrumpy>();
        aiHandler    = GetComponent <AiHandler>();

        InitiateAi();
    }
예제 #4
0
    private void UpdateNpcs(NetIncomingMessage incmsg)
    {
        int full = incmsg.ReadInt32();

        if (full > world.shipsNpc.Count)
        {
            full = world.shipsNpc.Count;
        }
        for (int j = 0; j < full; j++)
        {
            int         id      = incmsg.ReadInt32();
            Vector2     pos     = new Vector2(incmsg.ReadSingle(), incmsg.ReadSingle());
            float       rot     = incmsg.ReadSingle();
            Vector2     vel     = new Vector2(incmsg.ReadSingle(), incmsg.ReadSingle());
            float       hull    = incmsg.ReadSingle();
            float       shield  = incmsg.ReadSingle();
            AiDirection aiDir   = (AiDirection)incmsg.ReadByte();
            int         drTimer = incmsg.ReadInt32();
            for (int i = 0; i < world.shipsNpc.Count; i++)
            {
                if (world.shipsNpc[i].id == id)
                {
                    world.shipsNpc[i].Position = UpdatePosition(pos, world.shipsNpc[i].Position);
                    world.shipsNpc[i].velocity = vel;
                    world.shipsNpc[i].Rotation = UpdateRotation(rot, world.shipsNpc[i].Rotation);
                    world.shipsNpc[i].hull     = hull;
                    world.shipsNpc[i].shield   = shield;
                    if (world.shipsNpc[i].shield > 0 && world.shipsNpc[i].shieldTimer != 0)
                    {
                        world.shipsNpc[i].shieldTimer = 0;
                    }
                    world.shipsNpc[i].aiDir          = aiDir;
                    world.shipsNpc[i].directionTimer = drTimer;
                    break;
                }
            }
        }
    }