コード例 #1
0
    void RegisterControllers()
    {
        GameObject actionControllers = this.transform.parent.FindChild("ActionControllers").gameObject;

        movementController = actionControllers.GetComponent <MovementController>();
        aimingController   = actionControllers.GetComponent <AimingController>();
        firingController   = actionControllers.GetComponent <FiringController>();
        itemManager        = actionControllers.GetComponent <ItemManager>();
        corpus             = GetComponentInParent <CharacterCorpus> () as CharacterCorpus;
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        //Try this pattern: Check for component.
        //If not present, set null.
        //Implement default behaviour for null commponent, and log.

        aimingController = this.transform.parent.Find("ActionControllers").GetComponent <AimingController>();
        corpus           = this.transform.parent.GetComponent <CharacterCorpus> () as CharacterCorpus;
        targetSprite     = GetComponent <SpriteRenderer>();
    }
コード例 #3
0
 public CharacterComponentData(Character C)
 {
     character          = C;
     aimingController   = C.GetComponentInChildren <AimingController> () as AimingController;
     firingController   = C.GetComponentInChildren <FiringController> () as FiringController;
     movementController = C.GetComponentInChildren <MovementController> () as MovementController;
     movementActuator   = C.GetComponent <CharacterMovementActuator> () as CharacterMovementActuator;
     itemManager        = C.GetComponentInChildren <ItemManager>() as ItemManager;
     corpus             = C.GetComponent <CharacterCorpus> () as CharacterCorpus;
     characterTransform = movementActuator.transform;
 }
コード例 #4
0
    protected void CheckCharDeathAndDestroy()
    {
        CharacterCorpus casterCorpus = componentData.GetCharacterCorpus();

        if (casterCorpus != null)
        {
            if (!casterCorpus.GetIsAlive())
            {
                Destroy(this.gameObject);
            }
        }
    }
コード例 #5
0
    void SpawnObject(GameObject objectToSpawn)
    {
        GameObject spawnedObject = Instantiate(objectToSpawn, this.transform.position, Quaternion.identity);

        CharacterCorpus spawnedCorpus = spawnedObject.GetComponent <CharacterCorpus> () as CharacterCorpus;

        if (spawnedCorpus != null)
        {
            spawnedCorpusus.Add(spawnedCorpus);
        }
        numSpawned++;
    }
コード例 #6
0
    // Use this for initialization
    void Start()
    {
        animator          = GetComponent <Animator>();
        spriteRenderer    = GetComponent <SpriteRenderer>();
        characterMovement = this.transform.parent.GetComponent <CharacterMovementActuator>() as CharacterMovementActuator;
        characterContacts = this.transform.parent.GetComponent <CharacterContactSensor>() as CharacterContactSensor;
        aimingController  = this.transform.parent.FindChild("ActionControllers").GetComponent <AimingController>() as AimingController;
        corpus            = GetComponentInParent <CharacterCorpus> () as CharacterCorpus;
        hand = this.transform.parent.GetComponentInChildren <Hand> () as Hand;

        defaultColor = spriteRenderer.color;
    }
コード例 #7
0
 void OnCollisionEnter(Collision other)
 {
     if (itemState == ItemState.THROWN)
     {
         CharacterCorpus corpus = other.collider.GetComponent <CharacterCorpus> () as CharacterCorpus;
         if (corpus != null)
         {
             Character hitCharacter = other.collider.GetComponent <Character> () as Character;
             if (hitCharacter != throwingCharacter)
             {
                 corpus.TakeDamage(throwDamage, 0);                      //Team 0 will damage all characters.
                 SetItemToDiscarded();
             }
         }
         if (other.gameObject.layer == 8)
         {
             SetItemToDiscarded();
         }
     }
 }
コード例 #8
0
    // Use this for initialization
    void Start()
    {
        topography = (Topography)FindObjectOfType(typeof(Topography));

        StoreSpawners();

        if (startingArena)
        {
            ActivateArena();
        }

        GameObject playerGO = GameObject.FindGameObjectWithTag("Player");

        playerCharacter = playerGO.GetComponent <CharacterCorpus> () as CharacterCorpus;

        //Find the door 'stamp', and store the corner coordinates.
        ParseDoor();

        ParseActivationZone();
    }
コード例 #9
0
    protected void ResolveCollision(GameObject other)
    {
        CharacterCorpus corpus    = other.GetComponent <CharacterCorpus> () as CharacterCorpus;
        Character       character = other.GetComponent <Character> () as Character;

        if (corpus != null)
        {
            if (character != null)
            {
                if (character != this.componentData.GetCharacter())
                {
                    if (bounceCasterOnHit)
                    {
                        CharacterMovementActuator castingAcuator = componentData.GetMovementActuator();
                        if (castingAcuator != null)
                        {
                            if (castingAcuator.GetVerticalSpeed() < -1f)
                            {
                                if (castingAcuator.transform.position.y > corpus.transform.position.y)
                                {
                                    castingAcuator.BounceCommand(16f);
                                    corpus.TakeDamage(damage, firingTeam);
                                    corpus.TakeKnockback(worldLaunchVector, knockbackSpeed);
                                }
                            }
                        }
                    }
                    else
                    {
                        corpus.TakeDamage(damage, firingTeam);
                        corpus.TakeKnockback(worldLaunchVector, knockbackSpeed);
                    }

                    if (destroyOnCharacterContact)
                    {
                        DestroyProjectile();
                    }
                }
            }
        }
        if (other.gameObject.layer == 8)           //If other is terrain
        {
            if (destroyOnTerrainContact)
            {
                DestroyProjectile();
            }
        }

        if (deflectsProjectiles)
        {
            if (other.gameObject.layer == 13)               //If other is a projectile(ranged)
            {
                Rigidbody body = other.GetComponent <Rigidbody>() as Rigidbody;
                if (body != null)
                {
                    Transform castingTransform = componentData.GetCharacterTransform();
                    if (castingTransform != null)
                    {
                        Vector3 toOtherProj = other.transform.position - castingTransform.position;
                        toOtherProj.Normalize();
                        float otherProjSpeed = body.velocity.magnitude;

                        body.velocity = otherProjSpeed * toOtherProj;
                    }
                }
            }
        }
    }