예제 #1
0
    void Start()
    {
        _animator        = this.gameObject.GetComponent <Animator>();
        _doorSlideScript = _door1.GetComponent <DoorSlideScript>();

        _characterBehaviourScript = this.gameObject.GetComponent <CharacterBehaviourScript>();
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        CharacterBehaviourScript characterScript = gameObject.GetComponent <CharacterBehaviourScript> ();

        bool wasWalking = characterScript.wasWalking();
        bool isWalking  = characterScript.isWalking();

        if (isWalking && !wasWalking)           //Time.time > nextMoveSoundFire) {
        //playEvent ("Play_Walk_1");
        {
            playEvent("Walk_player1");
            //nextMoveSoundFire = Time.time + MoveSoundFireRate;
        }
        else if (!isWalking)
        {
            //stopEvent ("Play_Walk_1");
            stopEvent("Walk_player1");
        }
        bool jumped = characterScript.jumped();

        if (jumped)
        {
            playEvent("Jump_player1");
            characterScript.toggleJumpedThisStep();
        }
        bool wasHit = characterScript.wasHit();

        if (wasHit)
        {
            playEvent("LowHit_player1");
            characterScript.toggleWasHit();
        }
    }
    void Start()
    {
        _robot0Behaviour = _enemyRobots[0].GetComponent <EnemyRobotBehaviour>();
        _robot1Behaviour = _enemyRobots[1].GetComponent <EnemyRobotBehaviour>();

        _gunPickupScript          = this.gameObject.GetComponent <GunPickupScript>();
        _animator                 = this.gameObject.GetComponent <Animator>();
        _characterBehaviourScript = this.gameObject.GetComponent <CharacterBehaviourScript>();

        _charController = this.gameObject.GetComponent <CharacterController>();

        _aDSCamera.SetActive(false);
    }
예제 #4
0
 void Start()
 {
     _characterBehaviourScript = this.gameObject.GetComponent <CharacterBehaviourScript>();
 }
    bool collidedToStackAble(Collider2D other)
    {
        //Debug.Log ("collidedwith:");
        //Debug.Log (other.tag);
        GameObject collidedGameObject = other.gameObject;

        if (collidedGameObject.CompareTag("Player"))
        {
            //collided with plate:
            CharacterBehaviourScript script = collidedGameObject.GetComponentInParent <CharacterBehaviourScript> ();
            if (!script.collidedToPlateFromTop(other, rigidBodyOfInterest.transform.position.y))
            {
                //the collision must be from above, and to the plate, not to the feet!
                return(false);
            }
            if (script.getSizeOfStack() > 0)
            {
                //the pile has other pancakes, I do not sack on this pancake
                return(false);
            }
            else
            {
                if (script.checkIfHasSpaceForStacking())
                {
                    stackingToPlate = true;
                    ownerScript     = script;
                    ownerID         = ownerScript.getPlayerId();
                    return(true);
                }
                else
                {
                    //the stack is full, there can be no more pancakes
                    return(false);
                }
            }
        }
        else if (collidedGameObject.CompareTag("SinglePancakeConnectRigidBody"))
        {
            //Debug.Log ("collided with singePancake");
            //the collision is not with the base, it is with another pancake:
            //did I hit the stackable pancake rigid body?
            PancakeBehaviourScript script = collidedGameObject.GetComponentInParent <PancakeBehaviourScript> ();
            //Debug.Log ("is pancake stacked?");
            //Debug.Log (script.isStacked ());
            if (script.isStacked())
            {
                //Debug.Log ("pancake is stacked");
                //pancake is stacked:
                if (script.isTopPancake())
                {
                    //Debug.Log("Pancake is top pancake");
                    //pancake is top pancake,
                    if (collidedGameObject.transform.position.y < rigidBodyOfInterest.transform.position.y)
                    {
                        //the collision is from above
                        if (script.getOwnerScript().checkIfHasSpaceForStacking())
                        {
                            //the owner plate of the pancake it collided with has space:
                            //can stack now:
                            ownerScript = script.getOwnerScript();
                            ownerID     = ownerScript.getPlayerId();
                            return(true);
                        }
                    }
                }
            }
        }
        return(false);
    }