private void Start()
    {
        domMat    = animatedDom.GetComponent <MeshRenderer>().material;
        maskImage = domCanvas.transform.GetChild(0).GetComponent <Image>();
        rnd       = new System.Random(System.DateTime.Now.Millisecond);

        Point1TeamA.SetActive(false);
        Point2TeamA.SetActive(false);
        Point1TeamB.SetActive(false);
        Point2TeamB.SetActive(false);

        for (int i = 0; i < dominationPads.Length; i++)
        {
            DominationPadInfo info = new DominationPadInfo();
            info.pos        = dominationPads[i].position;
            info.icon       = dominationPads[i].GetComponent <Image>();
            info.listNumber = (byte)i;
            padList.Add(info);
        }
        GetComponent <CapsuleCollider>().enabled = false;
        sp = new StatePointer(StartState);
        //objectivesWon.text = "A= " + ScorePointA + " / " + "B= " + ScorePointB;


        domMat.SetFloat("_NeutralEvent", 1f);
        OwnerImage.color   = NoneOwned;
        MiddleCircle.color = NoneOwned;
    }
Esempio n. 2
0
 // State controller, Emotional states... Will always go back to regular happy face.
 void Happy()
 {
     ActiveHead.sprite = AliveHead;
     TimeSad           = 0f;
     TimeHappy         = 0f;
     HappySad          = Grounded;
 }
    private void WaitingForNextState()
    {
        if (isServer && !matchOver)
        {
            waitTimer += Time.deltaTime;
            if (waitTimer > 5f)
            {
                waitTimer = 0f;
                sp        = new StatePointer(StartState);

                int currentPad         = rnd.Next(0, padList.Count - 1);
                DominationPadInfo info = padList[currentPad];
                transform.position = info.pos;
                maskImage.sprite   = info.icon.sprite;
                padList.RemoveAt(currentPad);
                //GetComponent<MeshRenderer>().enabled = true;
                //GetComponent<CapsuleCollider>().enabled = true;
                resetPlayersOnPad();
                players = NetworkServer.objects;
                foreach (KeyValuePair <NetworkInstanceId, NetworkIdentity> entry in players)
                {
                    if (entry.Value.isLocalPlayer)
                    {
                        NetworkServer.FindLocalObject(entry.Key).GetComponent <VoiceActing>().NextCapPoint();
                    }
                }
                RpcActivatePoint(info.listNumber);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (doNextFrame)
        {
            moveUD           = padJumpHeight;
            state            = PlayerState.AirState;
            V0Air            = padJumpHeight;
            timeInAir        = 0f;
            sp               = new StatePointer(MovePlayerPositionAir);
            animStateChanged = 1;
            animGrounded     = 0;
            animJump         = 1;
            disableTimer     = 0f;
            doNextFrame      = false;
        }

        pickUpCd += Time.deltaTime;


        //if (!isLocalPlayer)
        //{

        //    return;
        //}
        float mouseX = input.getMouseX();

        RotatePlayer(mouseX);

        if (state == PlayerState.GroundState && input.getJumped())
        {
            Jump();
        }
        //DisableTimer gör så att man inte automatiskt blir grounded direkt efter ett hopp
    }
 private void StartState()
 {
     captureTimer += Time.deltaTime;
     if (team1 > team2)
     {
         bIsCapturing = false;
         if (!aIsCapturing)
         {
             aIsCapturing = true;
             captureTimer = 0f;
             state        = DominationState.Team1Capturing;
             RpcSetState((byte)DominationState.Team1Capturing);
         }
         if (captureTimer > timeToCapture)
         {
             sp = new StatePointer(TeamAState);
             RpcSetState((byte)DominationState.Team1);
             state        = DominationState.Team1;
             aIsCapturing = false;
             bIsCapturing = false;
             return;
         }
     }
     if (team2 > team1)
     {
         aIsCapturing = false;
         if (!bIsCapturing)
         {
             bIsCapturing = true;
             captureTimer = 0f;
             RpcSetState((byte)DominationState.Team2Capturing);
             state = DominationState.Team2Capturing;
         }
         if (captureTimer > timeToCapture)
         {
             sp    = new StatePointer(TeamBState);
             state = DominationState.Team2;
             RpcSetState((byte)DominationState.Team2);
             aIsCapturing = false;
             bIsCapturing = false;
             return;
         }
     }
     if (team1 == team2 && team1 == 0 && state != DominationState.Even)
     {
         captureTimer = 0f;
         aIsCapturing = false;
         bIsCapturing = false;
         state        = DominationState.Even;
         RpcSetState((byte)DominationState.Even);
     }
     if (team1 == team2 && team1 != 0 && state != DominationState.Contested)
     {
         captureTimer = 0f;
         aIsCapturing = false;
         bIsCapturing = false;
         state        = DominationState.Contested;
         RpcSetState((byte)DominationState.Contested);
     }
 }
Esempio n. 6
0
 //------------------------- System functions.
 // Use this for initialization
 void Start()
 {
     // Testing only///
     OriginalColor = gameObject.GetComponent <SpriteRenderer>().color;
     OkState       = dead;
     setStateOk();
 }
Esempio n. 7
0
 void Sad()
 {
     TimeSad += Time.deltaTime;
     if (TimeSad > 2)
     {
         HappySad = Happy;
     }
 }
Esempio n. 8
0
 void SuperHappy()
 {
     TimeHappy -= Time.deltaTime;
     if (TimeHappy < 0)
     {
         HappySad = Happy;
     }
 }
Esempio n. 9
0
 public void die()
 {
     currentState = dead;
     Scale       += 0.1f;
     setSize(Scale);
     Game.instance.SetDie(this.gameObject);
     //Destroy(gameObject);
 }
Esempio n. 10
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.CompareTag("Ground"))
     {
         canJump      = true;
         InitialJump  = false;
         currentState = Grounded;
     }
 }
    private bool Grounded()
    {
        float multiplier = 1f;

        if (state == PlayerState.GroundState)
        {
            multiplier = 1.2f;
        }
        if (Physics.Raycast(transform.position, Vector3.down, out hitInfoGround, multiplier * clampValue + 0.01f + ((pRBody.velocity.y < 0f) ? Mathf.Abs(pRBody.velocity.y * Time.fixedDeltaTime) : 0f)))
        {
            Vector3 colliderInfo = hitInfoGround.point;


            Vector3 tempPosition = transform.position;
            tempPosition.y = hitInfoGround.point.y + clampValue;
            //if (state == PlayerState.AirState)
            //{
            transform.position = tempPosition;
            //}else
            //{
            //    if (Vector3.Distance(hitInfoGround.point, transform.position)>clampValue+0.02f)
            //    {
            //        transform.position = transform.position + Vector3.down * 0.01f;
            //    }
            //}

            //transform.position = Vector3.Lerp(transform.position,tempPosition, 5f*Time.deltaTime);
            if (state != PlayerState.GroundState)
            {
                disableTimer = 0f;
                state        = PlayerState.GroundState;
                //Debug.Log("Changing to groundstate");
                sp = new StatePointer(MovePlayerPositionGround);
                animStateChanged = 1;
                animGrounded     = 1;
                animJump         = 0;
                //Debug.Log("Blir grounded");
            }

            return(true);
        }
        if (state != PlayerState.AirState)
        {
            state     = PlayerState.AirState;
            timeInAir = 0f;
            V0Air     = 0f;
            //Debug.Log("Changing to airstate");
            sp = new StatePointer(MovePlayerPositionAir);
            animStateChanged = 1;
            animGrounded     = 0;
            animJump         = 0;
            //Debug.Log("blir air state");
        }

        return(false);
    }
Esempio n. 12
0
    public void setStateOk()
    {
        currentState = OkState;
        //play idle animation
        Animator animator = gameObject.GetComponent <Animator>();

        animator.SetBool("ishurting", false);
        // Testing only....
        //gameObject.GetComponent<SpriteRenderer>().color = OriginalColor;
    }
Esempio n. 13
0
 void jump()
 {
     GetComponent <Animator>().SetBool("Jump", false);
     GetComponent <Animator>().SetTrigger("Jump");
     if (InitialJump)
     {
         canJump = false;
     }
     InitialJump  = true;
     TimeInAir    = 0;
     currentState = inAir;
 }
Esempio n. 14
0
    //---------------------------------------- Changes of States.
    public void setStateDying()
    {
        currentState = IsHurting;
        //play hurting animation
        Animator animator = gameObject.GetComponent <Animator>();

        animator.SetBool("ishurting", true);
        //play hurting SFX
        AudioSource[] hurtingSFX = GetComponents <AudioSource>();
        hurtingSFX[Random.Range(0, 3)].Play();
        // Testing only....
        //gameObject.GetComponent<SpriteRenderer>().color = new Color(1, 1, 1);
    }
    void Start()
    {
        input  = GetComponent <CharacterInput>();
        pRBody = GetComponent <Rigidbody>();

        capCol    = GetComponent <CapsuleCollider>();
        height    = capCol.height - 2 * capCol.radius;
        footsteps = GetComponent <Footsteps>();
        //latencyText.gameObject.SetActive(true);
        //nClient = GameObject.Find("Network Manager").GetComponent<NetworkManager>().client;
        //Debug.Log("Changing to ground state");
        sp = new StatePointer(MovePlayerPositionGround);
        animStateChanged = 1;
        animGrounded     = 1;
        animJump         = 0;
        //Debug.Log("Blir grounded");
    }
Esempio n. 16
0
 // Interact with other objects! How this will interact!
 // If this was larger I'd create multiple objects in code and have them call the Player component then have individual funcations for various effects.
 // But since it's so small it's simple enough to just compare tags.
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Bad Item"))
     {
         ActiveHead.sprite = DeadHead;
         HappySad          = Sad;
         playAudioClip(Boo);
     }
     if (collision.CompareTag("Good Item"))
     {
         ActiveHead.sprite = HappyHead;
         HappySad          = SuperHappy;
         playAudioClip(Yay);
         TimeSad    = 0f;
         TimeHappy += 1;
     }
 }
 private void Jump()
 {
     if (Time.timeScale != 0)
     {
         moveUD = jumpSpeed;
         //grounded = false;
         state     = PlayerState.AirState;
         V0Air     = jumpSpeed;
         timeInAir = 0f;
         //Debug.Log("Changing to air state");
         sp = new StatePointer(MovePlayerPositionAir);
         animStateChanged = 1;
         animGrounded     = 0;
         animJump         = 1;
         //Debug.Log("Blir air state");
         //Debug.Log("Hoppar");
         disableTimer = 0f;
     }
 }
Esempio n. 18
0
    public AudioClip Boo;       // For when he gets shit

    private void Start()
    {
        currentState = inAir;
        HappySad     = Grounded;
    }
Esempio n. 19
0
 /// <inheritdoc />
 public partial IntPtr GetPointer(StatePointer param);
    private void TeamBState()
    {
        if (!aIsCapturing && state != DominationState.Contested)
        {
            pointTimer += Time.deltaTime;
        }
        //if (pointTimer >= 1f)
        //{
        //    pointTeamB++;
        //    pointTimer = 0f;
        //}
        if (state != DominationState.Contested)
        {
            pointTeamB += Time.deltaTime;
        }
        //pointTeamB += Time.deltaTime;
        captureTimer += Time.deltaTime;
        if (team2 > team1 && state != DominationState.Team2)
        {
            state = DominationState.Team2;
            RpcSetState((byte)state);
        }
        if (team1 > team2)
        {
            if (!aIsCapturing)
            {
                aIsCapturing = true;
                captureTimer = 0f;
                RpcSetState((byte)DominationState.Team1Capturing);
                state = DominationState.Team1Capturing;
            }
            if (captureTimer > timeToCapture)
            {
                sp         = new StatePointer(TeamAState);
                pointTimer = 0f;
                RpcSetState((byte)DominationState.Team1);
                bIsCapturing = false;
                aIsCapturing = false;

                return;
            }
        }
        if (team1 == team2 && team1 == 0 && state != DominationState.Team2)
        {
            captureTimer = 0f;

            aIsCapturing = false;
            state        = DominationState.Team2;
            RpcSetState((byte)DominationState.Team2);
        }
        if (team1 == team2 && team1 != 0 && state != DominationState.Contested)
        {
            captureTimer = 0f;

            aIsCapturing = false;
            state        = DominationState.Contested;
            RpcSetState((byte)DominationState.Contested);
        }
        if (pointTeamB >= winConidtion)
        {
            sp    = new StatePointer(WaitingForNextState);
            state = DominationState.Waiting;
            RpcSetState((byte)state);
            RpcGivePointToTeam(1);
            ScorePointB++;
            if (ScorePointB == 1)
            {
                //tema0 vann första pointen
                players = NetworkServer.objects;
                foreach (KeyValuePair <NetworkInstanceId, NetworkIdentity> entry in players)
                {
                    if (entry.Value.isLocalPlayer)
                    {
                        NetworkServer.FindLocalObject(entry.Key).GetComponent <VoiceActing>().PointCaptured(1);
                    }
                }
            }
            if (CheckVictory(ScorePointB))
            {
                RpcTeamWins(1);
                status.text = "Team B won!";
                matchOver   = true;
            }
            aIsCapturing = false;
            bIsCapturing = false;
            captureTimer = 0f;
            pointTeamA   = 0;
            pointTeamB   = 0;
        }
    }
Esempio n. 21
0
 /// <inheritdoc />
 public abstract IntPtr GetPointer(StatePointer param);
Esempio n. 22
0
 /// <inheritdoc />
 public partial nint GetPointer(StatePointer param);