예제 #1
0
    void Shoot()
    {
        timer = 0f;

        gunAudio.Play();

        gunLight.enabled = true;

        gunParticles.Stop();
        gunParticles.Play();

        gunLine.enabled = true;
        gunLine.SetPosition(0, transform.position);

        shootRay.origin    = transform.position;
        shootRay.direction = transform.forward;

        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            SlimeHealth enemyHealth = shootHit.collider.GetComponent <SlimeHealth> ();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(damagePerShot, shootHit.point);
            }
            gunLine.SetPosition(1, shootHit.point);
        }
        else
        {
            gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range);
        }
    }
예제 #2
0
    void Start()
    {
        _transform = transform;
        //Build up the slime class with Name
        slimeClass = new SlimeClass(slimeName);
        photonView = GetComponent <PhotonView>();
        gm         = GameManager.Instance;
        //Join team list
        JoinTeamList();
        //PathFinding config
        move = GetComponent <SlimeMovement>();
        if (move != null)
        {
            move.SetUpNavMeshAgent(slimeClass);
        }
        //Slime Health Display config
        SlimeHealth health = GetComponent <SlimeHealth>();

        if (health != null)
        {
            health.SetUpSlimeHealth(slimeClass);
        }

        if (!photonView.isMine && !slimeClass.canSpawnInBattle)
        {
            DisplaySlime(false, true);
        }
        else if (slimeClass.canSpawnInBattle)
        {
            Invoke("SlimeComponentEnable", 0.3f);
        }
    }
예제 #3
0
 public void HideTheBuildingPanel(SlimeHealth h)
 {
     if (buildHealth == h)
     {
         Cancel();
     }
 }
예제 #4
0
    private void FindTheNearestEnemy()
    {
        mode = teamController.GetTeamSearchMode(transform);
        /* Kill the shortest distance enemy */
        if (mode == TeamController.SearchMode.distance || mode == TeamController.SearchMode.defense)
        {
            target = enemyList.OrderBy(o => DistanceCalculate(o.position, agent.position)).FirstOrDefault();
        }
        /* Kill the shortest distance enemy with lowest health precentage */
        else if (mode == TeamController.SearchMode.health)
        {
            target = enemyList.OrderBy(o => (o.root.GetComponent <SlimeHealth>().currentHealth / o.root.GetComponent <SlimeHealth>().startHealth)).
                     ThenBy(o => DistanceCalculate(o.position, agent.position)).FirstOrDefault();
        }
        /* Kill the shortest distance with class priority() */
        else if (mode == TeamController.SearchMode.priority)
        {
            target = enemyList.OrderBy(o => o.root.GetComponent <Slime>().GetSlimeClass().classPriority).
                     ThenBy(o => DistanceCalculate(o.position, agent.position)).FirstOrDefault();
        }

        if (target != null && target != prevTarget)
        {
            prevTarget = target;
            tarHealth  = target.root.GetComponent <SlimeHealth>();
            range      = slime.scaleRadius + slime.actionRange + target.root.GetComponent <Slime>().GetSlimeClass().scaleRadius;
            //Client set the target
            photonView.RPC("RPC_ClientSetTarget", PhotonTargets.Others, target.root.gameObject.GetPhotonView().viewID);
        }
    }
예제 #5
0
 void Start()
 {
     photonView  = GetComponent <PhotonView>();
     slime       = GetComponent <Slime>().GetSlimeClass();
     agent       = GetComponent <Slime>().GetAgent();
     movement    = GetComponent <SlimeMovement>();
     health      = GetComponent <SlimeHealth>();
     gameManager = GameManager.Instance;
 }
예제 #6
0
    public void Show(Transform s, SlimeHealth h)
    {
        buildHealth = h;
        arrow.PositionArrow(s);

        teamController.SetControlPanelDisplay(false);
        teamController.SetControlButtonDisplay(false);
        chattingPanel.SetChatButtonDisplay(false);
        chattingPanel.SetChatPanelDisplay(false);
        BuildingPanelDisplay(true);
    }
예제 #7
0
    private void RPC_ClientSetTarget(int targetView)
    {
        int index = enemyList.FindIndex(x => x.root.gameObject.GetPhotonView().viewID == targetView);

        /* if index >= 0, target is found and not equal to null */
        if (index != -1)
        {
            target    = enemyList[index];
            tarHealth = target.root.GetComponent <SlimeHealth>();
        }
    }
예제 #8
0
 void Start()
 {
     s      = transform.parent.GetComponent <Slime>();
     health = transform.parent.GetComponent <SlimeHealth>();
     model  = s.GetModel();
     agent  = s.GetAgent();
     slime  = s.GetSlimeClass();
     GetComponent <SphereCollider>().radius = slime.detectRadius;
     enemyTag    = (transform.parent.tag == "Team_RED") ? "Team_BLUE" : "Team_RED";
     photonView  = transform.parent.GetComponent <PhotonView>();
     gameManager = GameManager.Instance;
 }
예제 #9
0
    void Awake()
    {
        game = Game.GetGame();

        player         = GameObject.FindGameObjectWithTag("Player").transform;
        playerHealth   = player.GetComponent <PlayerHealth>();
        playerMove     = player.GetComponent <PlayerMovement>();
        enemyHealth    = GetComponent <SlimeHealth>();
        enemyAttacking = GetComponent <EnemyAttacking> ();
        anim           = GetComponent <Animation>();

        nav = GetComponent <NavMeshAgent>();

        SetNavEnabled(false);

        isStunned = false;
    }
예제 #10
0
    // apply slime stats here!
    public void SetPhaseStats(int index, GameObject slime)
    {
        // get phase by index
        SlimeStatDefinition phase = slimePhases[index];
        SlimeHealth         sh    = slime.GetComponent <SlimeHealth>();

        sh.PhaseIndex      = index;
        sh.PhaseDefinition = phase;
        // hp
        sh.initialHealth = phase.hp;
        sh.Refresh();
        // apply scale
        slime.transform.localScale = phase.scale;
        // speed
        slime.GetComponent <BasicFollowMovement>().UpdateSpeed(phase.speed);
        // damage
        slime.GetComponent <EnemyTouchHazard>().damage = phase.damage;
    }
    void OnTriggerEnter(Collider other)
    {
        Slime s = other.transform.root.GetComponent <Slime>();

        if (s == null)
        {
            return;
        }

        Transform  targetSlime = other.transform.root;
        SlimeClass slimeClass  = s.GetSlimeClass();

        if (targetSlime.tag == rootObject.tag && !slimeClass.isBuilding)
        {
            SlimeHealth h = targetSlime.GetComponent <SlimeHealth>();
            buffList.Add(h);
            h.buffIndex++;
            h.SetDamageReduced(guardian.GetDamageReducedPercentage());
        }
    }
예제 #12
0
        protected override void Build()
        {
            // Get GameObjects
            Prefab = CustomBase != null?PrefabUtils.CopyPrefab(CustomBase) : PrefabUtils.CopyPrefab(BaseItem);

            Prefab.name = NamePrefix + Name;
            Prefab.transform.localScale = Scale * Definition.PrefabScale;

            // Load Components
            SlimeAppearanceApplicator app = Prefab.GetComponent <SlimeAppearanceApplicator>();
            SlimeVarietyModules       mod = Prefab.GetComponent <SlimeVarietyModules>();
            SlimeEat    eat = Prefab.GetComponent <SlimeEat>();
            SlimeHealth hp  = Prefab.GetComponent <SlimeHealth>();

            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            // Setup Components
            app.SlimeDefinition = Definition;
            app.Appearance      = Definition.AppearancesDefault[0];
            mod.baseModule      = Definition.BaseModule;
            mod.slimeModules    = Definition.SlimeModules;

            eat.slimeDefinition    = Definition;
            eat.minDriveToEat      = MinDriveToEat;
            eat.drivePerEat        = DrivePerEat;
            eat.agitationPerEat    = AgitationPerEat;
            eat.agitationPerFavEat = AgitationPerFavEat;

            hp.maxHealth = Health;

            body.mass = Mass;
            vac.size  = Size;
            iden.id   = ID;

            // Get rid of unneeded components
            Object.Destroy(Prefab.GetComponent <PinkSlimeFoodTypeTracker>());
        }
    void OnTriggerExit(Collider other)
    {
        Slime s = other.transform.root.GetComponent <Slime>();

        if (s == null)
        {
            return;
        }

        Transform  targetSlime = other.transform.root;
        SlimeClass slimeClass  = s.GetSlimeClass();

        if (targetSlime.tag == rootObject.tag && !slimeClass.isBuilding)
        {
            SlimeHealth h = targetSlime.GetComponent <SlimeHealth>();
            h.buffIndex--;
            if (h.buffIndex == 0)
            {
                buffList.Remove(h);
                h.SetupDefaultDamageReduced();
            }
        }
    }
예제 #14
0
 // Use this for initialization
 void Start()
 {
     slimeMovement = gameObject.GetComponent <SlimeMovement>();
     slimeHealth   = gameObject.GetComponent <SlimeHealth>();
 }
예제 #15
0
        /// <summary>Builds this Item</summary>
        protected override void Build()
        {
            //foreach (Identifiable.Id slime in Identifiable.SLIME_CLASS)
            //{
            // Make new Definition
            SlimeDefinition other  = SlimeUtils.GetDefinitionByID(Identifiable.Id.PINK_SLIME);
            SlimeDefinition newDef = Definition.CombineForLargo(other);

            // Translation
            DefTranslation.Add(newDef.IdentifiableId, Regex.Replace(Definition.Name, "(\\B[A-Z])", " $1") + " " + Regex.Replace(other.Name, "(\\B[A-Z])", " $1") + " Largo");

            //if (newDef == null)
            //	continue;

            // Get GameObjects
            Prefab      = PrefabUtils.CopyPrefab(BaseItem);
            Prefab.name = NamePrefix + Definition.Name + other.Name;
            Prefab.transform.localScale = Scale * newDef.PrefabScale;

            // PRIMARY SETUP
            // Load Components
            SlimeAppearanceApplicator app = Prefab.GetComponent <SlimeAppearanceApplicator>();
            SlimeVarietyModules       mod = Prefab.GetComponent <SlimeVarietyModules>();

            // Setup Components
            app.SlimeDefinition = newDef;
            mod.baseModule      = newDef.BaseModule;
            mod.slimeModules    = newDef.SlimeModules;

            mod.Assemble();

            // SECONDARY SETUP
            // Load Components
            SlimeEat    eat = Prefab.GetComponent <SlimeEat>();
            SlimeHealth hp  = Prefab.GetComponent <SlimeHealth>();

            Rigidbody    body = Prefab.GetComponent <Rigidbody>();
            Vacuumable   vac  = Prefab.GetComponent <Vacuumable>();
            Identifiable iden = Prefab.GetComponent <Identifiable>();

            // Setup Components
            eat.slimeDefinition    = newDef;
            eat.minDriveToEat      = MinDriveToEat;
            eat.drivePerEat        = DrivePerEat;
            eat.agitationPerEat    = AgitationPerEat;
            eat.agitationPerFavEat = AgitationPerFavEat;

            hp.maxHealth = Health;

            body.mass = Mass;
            vac.size  = Size;
            iden.id   = newDef.IdentifiableId;

            // TERTIARY SETUP
            // Load Components
            SlimeEmotions emot  = Prefab.GetComponent <SlimeEmotions>();
            SlimeEmotions emot2 = BaseItem.GetComponent <SlimeEmotions>();

            emot.initAgitation = emot2.initAgitation;
            emot.initFear      = emot2.initFear;
            emot.initHunger    = emot2.initHunger;

            // Add to Largo List
            Prefabs.Add(newDef.IdentifiableId, Prefab);
            //}
        }
예제 #16
0
 public void Seek(Transform _target, float _attackDamage, SlimeHealth health, string _tag)
 {
     bulletSetUp(_tag, _target, _attackDamage);
     tarHealth = health;
 }
예제 #17
0
 public void SetTarget(Transform _target)
 {
     target    = _target;
     tarHealth = target.root.GetComponent <SlimeHealth>();
 }