Beispiel #1
0
        public void MoveTo_Returns_False_When_Object_Does_Not_Move()
        {
            var thing  = new LivingThing(1, 1, 1, 1, 1, 1, 1, new Mock <ICuskEngine>().Object);
            var result = thing.MoveTo(0, 0);

            Assert.IsFalse(result);
        }
Beispiel #2
0
    private void OnTriggerEnter(Collider other)
    {
        //Trigger the attack
        //Debug.Log("detected " + other.transform.root.name);

        if (freezeDamage)
        {
            return;
        }

        if (other.isTrigger)
        {
            return;
        }

        if (other.transform.root.tag == "Player" || friendlyFire)
        {
            LivingThing l = other.GetComponentInParent <LivingThing>();
            if (l != null)
            {
                l.takeDamage(damage);
                //Debug.Log("hit " + other.transform.root.name);
            }
        }
    }
Beispiel #3
0
    private void UpdateAttachments(LivingThing owner)
    {
        foreach (Attachment attachment in attachments)
        {
            switch (attachment.attachTo)
            {
            case BodyPart.Head:
                attachment.transform.SetParent(owner.head);
                break;

            case BodyPart.LeftHand:
                attachment.transform.SetParent(owner.leftHand);
                break;

            case BodyPart.RightHand:
                attachment.transform.SetParent(owner.rightHand);
                break;

            case BodyPart.LeftFoot:
                attachment.transform.SetParent(owner.leftFoot);
                break;

            case BodyPart.RightFoot:
                attachment.transform.SetParent(owner.rightFoot);
                break;
            }
            attachment.transform.position = attachment.transform.parent.position;
            attachment.transform.rotation = attachment.transform.parent.rotation;
            attachment.transform.Translate(attachment.offsetPosition);
            attachment.transform.Rotate(attachment.offsetRotation, Space.Self);
            attachment.transform.gameObject.SetActive(true);
        }
    }
Beispiel #4
0
 // Start is called before the first frame update
 void Start()
 {
     rigidBody            = GetComponent <Rigidbody2D>();
     livingThing          = GetComponent <LivingThing>();
     weaponHolder         = GetComponent <WeaponHolder>();
     triggerDownAfterShot = false;
 }
Beispiel #5
0
 // Start is called before the first frame update
 void Start()
 {
     livingThing  = GetComponent <LivingThing>();
     rigidBody    = GetComponent <Rigidbody2D>();
     pathFinder   = GetComponent <PathFinder>();
     shouldLookAt = false;
     state        = State.Wandering;
 }
Beispiel #6
0
 public void EntityOnClick(LivingThing thing)
 {
     EntityScrollList.Definition.SetActive(true);
     EntityScrollList.Header.SetActive(true);
     EntityScrollList.NothingSelected.SetActive(false);
     GameObject.Find("EntityName").GetComponent <Text>().text = thing.getName();
     GameObject.Find("EntityDef").GetComponent <Text>().text  = thing.getDefinition();
 }
Beispiel #7
0
 public void TargetSomething(LivingThing newTarget)
 {
     if (Target != null)
     {
         Target.gameObject.GetComponent <Renderer>().material.color = Color.red;
     }
     Target = newTarget;
     Target.gameObject.GetComponent <Renderer>().material.color = Color.blue;
 }
Beispiel #8
0
    protected void RpcChannelCancel(int viewId)
    {
        LivingThing activator = PhotonNetwork.GetPhotonView(viewId).GetComponent <LivingThing>();

        if (activator.photonView.IsMine)
        {
            activator.OnDealDamage -= Interrupt;
        }
        OnChannelCancel(activator);
    }
Beispiel #9
0
        private static LivingThing CreateLivingThingThatCanMoveAnywhere()
        {
            var mock = new Mock <ICuskEngine>();

            mock.Setup(m => m.EntityCanMoveTo(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <ICuskEntity>())).Returns(true);

            var thing = new LivingThing(1, 1, 1, 1, 1, 1, 1, mock.Object);

            return(thing);
        }
Beispiel #10
0
        public void MoveTo_Returns_False_When_Object_Is_Blocked()
        {
            var mock = new Mock <ICuskEngine>();

            mock.Setup(m => m.EntityCanMoveTo(1, 1, It.IsAny <ICuskEntity>())).Returns(false);

            var thing  = new LivingThing(1, 1, 1, 1, 1, 1, 1, mock.Object);
            var result = thing.MoveTo(1, 1);

            Assert.IsFalse(result);
        }
Beispiel #11
0
        public Buff BaseInitialize(LivingThing wearer)
        {
            Buff buff = Instantiate(this);

            buff.Wearer          = wearer;
            buff.TimeLeft        = Duration;
            buff.OnBuffStart    += buff.OnApply;
            buff.OnBuffTick     += buff.Tick;
            buff.OnBuffFinished += buff.OnRemove;
            return(buff.Initialize(wearer));
        }
Beispiel #12
0
 // Start is called before the first frame update
 void Start()
 {
     livingThing = gameObject.GetComponent <LivingThing>();
     livingThing.OnDeathEvent.AddListener(OnDeath);
     Rend        = gameObject.GetComponent <Renderer>();
     AttackTimer = 0;
     player      = GlobalData.GetPlayerAndAddListener(this);
     if (player != null)
     {
         player.livingThing.OnDeathEvent.AddListener(PlayerDied);
     }
 }
Beispiel #13
0
 public void TakeDamage(float damage, LivingThing attacker)
 {
     Health -= damage;
     if (TakeDamageEvent != null)
     {
         TakeDamageEvent(damage, attacker);
     }
     if (Health.GetVal() <= 0)
     {
         Die();
     }
 }
Beispiel #14
0
 private void Update()
 {
     if (debug_UpdateAttachmentsEveryFrame)
     {
         LivingThing owner = GetComponentInParent <LivingThing>();
         if (owner == null)
         {
             return;
         }
         UpdateAttachments(owner);
     }
 }
Beispiel #15
0
 private void OnTriggerEnter2D(Collider2D col)
 {
     Debug.Log("Hit:" + col.gameObject.name);
     if (col.gameObject != Source)
     {
         LivingThing livingThing = col.gameObject.GetComponent <LivingThing>();
         if (livingThing != null)
         {
             livingThing.Die(); // OOF
         }
         Destroy(gameObject);
     }
 }
Beispiel #16
0
 private void AddEntities()
 {
     pair.Clear();
     for (int i = 0; i < itemList.Count; ++i)
     {
         LivingThing currentItem = itemList[i];
         GameObject  newItem     = entityObject.GetObject();
         newItem.transform.SetParent(contentPanel);
         EntityInfo element = newItem.GetComponent <EntityInfo>();
         element.Setup(currentItem);
         pair.Add(new KeyValuePair <string, GameObject>(currentItem.getName(), newItem));
     }
 }
Beispiel #17
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.isTrigger)
        {
            return;
        }
        LivingThing l = other.gameObject.GetComponentInParent <LivingThing>();

        if (l != null)
        {
            dealDamage(l);
            targetHit = true;
        }
    }
        static void PolymorphismExample()
        {
            LivingThing livingObj = new LivingThing();

            livingObj.PolyFunction();

            LivingThing animalObj = new Animal();

            animalObj.PolyFunction();

            LivingThing vertibrateObj = new Vertibrate();

            vertibrateObj.PolyFunction();
        }
Beispiel #19
0
    protected void RpcUnequip(int owner_id)
    {
        LivingThing owner = PhotonNetwork.GetPhotonView(owner_id).GetComponent <LivingThing>();

        for (int i = 0; i < skillSetReplacements.Length; i++)
        {
            if (skillSetReplacements[i] != null)
            {
                owner.control.skillSet[i] = null;
            }
        }
        DetachAttachments();
        OnUnequip(owner);
    }
Beispiel #20
0
    public bool dealDamage(LivingThing target, int damageAmount)
    {
        if (target != null)
        {
            int finalDamage = (int)(damageAmount * Mathf.Pow(levelDamageCoef, level - 1) * manager.bonusDamageCoef) + manager.bonusDamage;

            totalDamage += Mathf.Max(0, Mathf.Min(finalDamage, target.getCurrentLife()));
            target.takeDamage(finalDamage);
            if (target.getCurrentLife() <= 0)
            {
                totalKills++;
            }
        }

        return(target != null);
    }
Beispiel #21
0
    public void StartActivate(LivingThing activator)
    {
        if (!activator.photonView.IsMine)
        {
            Debug.LogError("StartActivate() can be only called with local LivingThing!");
            return;
        }
        photonView.RPC("RpcChannelStart", RpcTarget.All, activator.photonView.ViewID);

        Channel newChannel = new Channel(channel.channelValidator, channel.duration, channel.canMove, channel.canAttack, channel.canUseAbility, channel.canBeCanceledByCaster,
                                         () => { photonView.RPC("RpcChannelSuccess", RpcTarget.All, activator.photonView.ViewID); },
                                         () => { photonView.RPC("RpcChannelCancel", RpcTarget.All, activator.photonView.ViewID); });

        activator.control.StartChanneling(newChannel);

        activator.OnDealDamage += Interrupt;
        dict.Add(new KeyValuePair <LivingThing, Channel>(activator, newChannel));
    }
Beispiel #22
0
 private void OnTriggerEnter2D(Collider2D col)
 {
     Debug.Log("Hit:" + col.gameObject.name);
     if (col.gameObject != Source)
     {
         LivingThing livingThing = col.gameObject.GetComponent <LivingThing>();
         if (livingThing != null)
         {
             livingThing.Die(); // OOF
             Destroy(gameObject);
         }
         FireBall fb = col.gameObject.GetComponent <FireBall>();
         if (fb != null)
         {
             LivedTime -= LifeTime * (2 * (GrowthSpeed - 1));
             gameObject.transform.localScale *= GrowthSpeed;
         }
     }
 }
Beispiel #23
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && !Input.GetMouseButton(1))
        {
            float       closestDistance = Vector3.Distance(Input.mousePosition, Camera.main.WorldToScreenPoint(enemys[0].gameObject.transform.position));
            LivingThing closest         = enemys[0];

            for (int i = 1; i < enemys.Count; i++)
            {
                float dist = Vector3.Distance(Input.mousePosition, Camera.main.WorldToScreenPoint(enemys[i].gameObject.transform.position));
                if (dist < closestDistance)
                {
                    closestDistance = dist;
                    closest         = enemys[i];
                }
            }
            player.TargetSomething(closest);
        }
    }
Beispiel #24
0
 private void OnTriggerEnter2D(Collider2D col)
 {
     if (Source != null)
     {
         Debug.Log("Hit:" + col.gameObject.name);
         if (col.gameObject != Source && col.GetComponent <Scatter>() == null)
         {
             LivingThing livingThing = col.gameObject.GetComponent <LivingThing>();
             if (livingThing != null)
             {
                 livingThing.Die(); // OOF
             }
             Destroy(gameObject);
         }
     }
     else
     {
         Debug.Log("Source was null.....");
     }
 }
Beispiel #25
0
    protected override void OnChannelSuccess(LivingThing activator)
    {
        PlayerItemBelt belt = activator.GetComponent <PlayerItemBelt>();

        if (belt == null)
        {
            return;
        }
        if (owner != null)
        {
            return;
        }
        owner = activator;
        if (belt.AddConsumable(this))
        {
            transform.SetParent(activator.transform);
            transform.position = activator.transform.position;
            gameObject.SetActive(false);
        }
    }
 void SearchTarget()
 {
     if (target != null)
     {
         LivingThing lt = target.GetComponent<LivingThing>();
         if (Vector3.Distance(target.transform.position, crystal.transform.position) > maxDistance || !target.gameObject.activeInHierarchy || (lt != null && lt.life <= 0))
         {
             target = null;
         }
     }
     if (target == null)
     {
         GameObject[] enemies = GameObject.FindGameObjectsWithTag(targetName);
         if (enemies.Length >= 1)
         {
             GameObject t = enemies[0];
             LivingThing ltt = t.GetComponent<LivingThing>();
             if(ltt == null || ltt.life <= 0)
             {
                 t = null;
             }
             float distT = t == null ? float.PositiveInfinity : Vector3.Distance(crystal.transform.position, t.transform.position);
             for (int i = 1; i < enemies.Length; ++i)
             {
                 GameObject e = enemies[i];
                 LivingThing ltt2 = e.GetComponent<LivingThing>();
                 float distTmp = Vector3.Distance(crystal.transform.position, e.transform.position);
                 bool distance = distTmp < distT && distTmp <= maxDistance;
                 if (t == null && distance  || (ltt2 != null && ltt2.life > 0) && distance)
                 {
                     t = e;
                     distT = distTmp;
                 }
             }
             if (distT <= maxDistance)
             {
                 target = t.GetComponent<LivingThing>();
             }
         }
     }
 }
        static void InheritanceExample()
        {
            var vertibrate = new Vertibrate("Human");

            Console.WriteLine("Type of Vertibrate => " + vertibrate.GetType());
            vertibrate.VertibratePublicName = "";

            var animalV = (Animal)vertibrate;

            animalV.publicName            = "";
            animalV.publicLivingThingName = "";

            var livingthingV = (LivingThing)vertibrate;

            livingthingV.publicLivingThingName = "";

            // var plant = (Plant)vertibrate;

            var newPlant         = new Plant();
            var plantlivingThing = (LivingThing)newPlant;

            var animal = new Animal();

            animal.publicName            = "TestpublicName";
            animal.publicLivingThingName = "publicLivingThingName";
            var animallivingThing = (LivingThing)animal;


            LivingThing[] livingThings = new LivingThing[2];
            livingThings[0] = new LivingThing();
            livingThings[1] = new Animal();
            Array.Resize(ref livingThings, livingThings.Length + 2);
            livingThings[2] = new Vertibrate();
            livingThings[3] = new Plant();


            Animal[] animals = new Animal[3];
            animals[0] = new Animal();
            animals[1] = new Vertibrate();
            //animals[2] = new Plant();
        }
Beispiel #28
0
        public void LivingThing_Stores_Values_When_Created()
        {
            int MaxHP        = 10;
            int MaxMP        = 11;
            int Strength     = 12;
            int Intelligence = 13;
            int Dexterity    = 14;
            int Consitution  = 15;
            int Wisdom       = 16;
            var thing        = new LivingThing(MaxHP, MaxMP, Strength, Intelligence, Dexterity, Consitution, Wisdom, cuskEngine);

            Assert.AreEqual(MaxHP, thing.HP);
            Assert.AreEqual(MaxMP, thing.MP);
            Assert.AreEqual(Strength, thing.Strength);
            Assert.AreEqual(Intelligence, thing.Intelligence);
            Assert.AreEqual(Dexterity, thing.Dexterity);
            Assert.AreEqual(Consitution, thing.Constitution);
            Assert.AreEqual(Wisdom, thing.Wisdom);
            Assert.AreEqual(0, thing.OriginalX);
            Assert.AreEqual(0, thing.OriginalY);
            Assert.AreEqual(0, thing.Experience);
            Assert.IsNotNull(thing.ID);
        }
Beispiel #29
0
 public void Setup(LivingThing currentItem)
 {
     thing = currentItem;
     theNameOfThing.text = thing.getName();
     livingThingButton.onClick.AddListener(delegate { EntityOnClick(thing); });
 }
Beispiel #30
0
 protected abstract void OnChannelSuccess(LivingThing activator);
Beispiel #31
0
 protected abstract void OnChannelCancel(LivingThing activator);